OCR accuracy test: how to measure it on your own documents
A vendor's "99% accurate" is measured on somebody else's paper. If you need to know whether OCR will handle your receipts, your lab reports or your passport, you have to test your own pages — and you can do it in under an hour with a text file, a spreadsheet and a short script.
Disclosure: we build ScanWisp, which runs OCR locally in the browser. This guide describes a measurement method rather than publishing a headline accuracy figure, because a single figure would hide exactly the differences the method is meant to expose.
I've read a lot of scanner marketing. The accuracy claims are almost never false in the narrow sense. They're measured on a clean, flat, well-lit corpus in a handful of languages, at a resolution you'll never reproduce with a phone over a kitchen table. Then the number gets printed next to a picture of someone scanning a crumpled receipt, and the implication does the rest.
The useful question isn't "how accurate is this OCR?" It's "how accurate is it on the pages I actually have, in the language I actually need, and what kind of mistake does it make?" That question has a concrete answer, and you can get it yourself.
Why a single accuracy number tells you almost nothing
Four things move an OCR score, and marketing pages usually disclose none of them:
- The corpus. Clean laser print at 300 dpi is close to solved. A phone photo of a curled receipt under a warm lamp is not. The gap between those two conditions is much larger than the gap between most modern engines on the easy one.
- The language. Latin-script languages share an alphabet and often share a model. Chinese, Japanese and Korean need different models, and a tool that is excellent in English can be mediocre in Japanese without anyone lying about it.
- The metric. Character error rate and word error rate tell different stories. A single wrong digit in an account number is a trivial character error and a catastrophic field error.
- The normalisation. If you ignore case, punctuation and spacing, scores go up. If you score those, they go down. Both can be legitimate, but you have to say which one you did.
So the method matters more than the headline. The rest of this piece is the method.
Pick a metric you can defend
For most document work, character error rate (CER) is the honest starting point. It's the number of single-character edits — insertions, deletions, substitutions — needed to turn the OCR output into the correct text, divided by the number of characters in the correct text.
Word error rate (WER) is the same idea at word level. It's more intuitive for prose and less useful for identifiers, because one wrong character in a long word still counts as one word error, while one wrong character in a short number is also one word error. For invoices, passport numbers and lab values, CER plus a field check is better.
Here's the arithmetic, with made-up numbers so the shape is clear. Suppose a page has 1,000 characters after normalisation and the OCR output needs 3 edits to match. That's a CER of 0.003, or 0.3%. On an A4 page of about 2,000 characters, the same rate is roughly six wrong characters per page. That's usually fine for search and usually not fine for a bank account number. The rate is the same; the consequence isn't.
Decide the normalisation rules before you score, and write them down. At minimum: case, whitespace, line breaks, curly versus straight quotes, en dash versus hyphen, and whether accents count. Apply the same rules to the reference text and the OCR output. If you change the rules halfway through, you're not measuring the tool any more.
Build a sample set that looks like your paper
Ten pages is enough to see a pattern; twenty gives you more confidence. The point is variety, not volume. Include the conditions you actually scan in, including the bad ones. A test set of ten perfect laser prints will tell you what you already know.
| Page type | What it stresses | What to record |
|---|---|---|
| Clean laser print | The easy case. Establishes your ceiling. | CER, time |
| Phone photo at an angle | Perspective correction and edge detection. | CER before and after correction |
| Low light or hard shadow | Thresholding and contrast enhancement. | CER, visible dropouts |
| Thermal receipt | Faint, narrow, curled paper. | CER on amounts and dates |
| Form with handwriting | Printed labels plus handwritten answers. | Which fields survived |
| Table of numbers | Reading order and decimal points. | Field-level accuracy |
| Two languages on one page | Model selection and script switching. | CER per language |
| Small print and footnotes | Resolution limits. | CER on the smallest text |
| Stamped or initialled page | Overlapping marks. | Missed or merged characters |
| Glossy or laminated page | Glare and specular highlights. | Which lines were lost |
If you're testing two tools, use the same photographs for both. Don't let each app take its own picture; you'd be comparing cameras and auto-capture, not OCR.
Type the ground truth yourself
This is the tedious part and it's the part that makes the result trustworthy. Open each page and type what it says into a plain UTF-8 text file. Don't copy from an OCR result, even a different tool's; that just measures agreement between two engines.
- Include punctuation, numbers, accents and diacritics. Those are where the interesting errors live.
- Don't reproduce line breaks. Join the text into a continuous string, or replace line breaks with a single space, then apply the same rule to the OCR output.
- Decide what to do with hyphenated words split across lines. The simplest defensible rule is to join them and drop the hyphen, and to do the same to the OCR text.
- For Chinese, Japanese and Korean, count characters and don't insert spaces. For Latin scripts, decide whether you're scoring whitespace at all. The script below drops whitespace for the character test.
Keep one file per page: p01-truth.txt, p01-ocr.txt, and so on. When
you change a setting, save the OCR output under a new name rather than overwriting it. Future
you will want the comparison.
Run the test and score it
For each page, record the conditions before you look at the result: device, browser or app version, language selected, enhancement mode, whether the image was corrected, and how long recognition took. A score without those notes is hard to interpret later.
ScanWisp can export the recognised text as TXT, which is exactly what you need for scoring. Other tools often bury the text inside the PDF; if there's no TXT export, you can extract the text layer with a PDF tool, but be aware that some extractors reorder columns.
Then score. You can do this by hand for a small set, but a script removes arithmetic mistakes. This is a complete, dependency-free Python program: give it the truth file and the OCR file, and it prints the character count, the edit count and the CER.
import re
import sys
import unicodedata
def normalise(text):
text = unicodedata.normalize("NFC", text)
text = text.casefold()
text = re.sub(r"[\u2018\u2019]", "'", text)
text = re.sub(r"[\u201c\u201d]", '"', text)
text = re.sub(r"[\u2013\u2014]", "-", text)
text = re.sub(r"\s+", "", text)
return text
def edit_distance(a, b):
previous = list(range(len(b) + 1))
for i, char_a in enumerate(a, 1):
current = [i]
for j, char_b in enumerate(b, 1):
current.append(min(
previous[j] + 1,
current[j - 1] + 1,
previous[j - 1] + (char_a != char_b),
))
previous = current
return previous[-1]
truth = normalise(open(sys.argv[1], encoding="utf-8").read())
ocr = normalise(open(sys.argv[2], encoding="utf-8").read())
if not truth:
sys.exit("truth file is empty after normalisation")
edits = edit_distance(truth, ocr)
print(f"characters={len(truth)} edits={edits} CER={edits / len(truth):.4f}")
The script strips all whitespace before comparing, so it measures character fidelity and ignores word spacing. That's deliberate for identifiers and CJK text. If spacing matters for your document, score word by word as well, using the same normalisation except the whitespace step.
One caveat: the edit distance is quadratic in the length of the strings. A single page is fine. If you feed it a 40-page book as one string, it will be slow. Score page by page.
A scorecard you can fill in
Copy this into a spreadsheet and add a row per page. Leave the result columns blank until you have actually run the page; the table below is a template, not a set of results.
| Page | Category | Characters | Edits | CER | Notes |
|---|---|---|---|---|---|
| p01 | Clean print | — | — | — | — |
| p02 | Angled photo | — | — | — | — |
| p03 | Low light | — | — | — | — |
| p04 | Receipt | — | — | — | — |
| p05 | Form + handwriting | — | — | — | — |
| p06 | Numeric table | — | — | — | — |
| p07 | Two languages | — | — | — | — |
| p08 | Small print | — | — | — | — |
Report the results by category, not as one average. "4% on receipts, 0.4% on clean print" is a useful finding. "1.8% overall" hides the only number you needed.
The errors worth looking for
CER tells you how much went wrong. Reading the diffs tells you what went wrong, which is what determines whether you can trust the output. These are the patterns I look for first.
| Pattern | Example | Why it happens | What to do |
|---|---|---|---|
| Lookalike letters | rn → m, 1 →
l or I | Similar shapes at low resolution. | Raise the effective resolution; check names and codes by eye. |
| Digit/letter swaps | 0 → O, 5 →
S, 2 → Z | Same reason, worse on sans-serif fonts. | Never trust an identifier without a second look. |
| Lost decimal points | 1.50 → 150 | The dot is a few pixels; thresholding erases it. | Use grayscale rather than hard black and white for numeric pages. |
| Accents stripped | café → cafe, Müller
→ Muller | Model or normalisation drops the diacritic. | Choose the right language; check names against the original. |
| German ß | Straße → Strasse | Transliteration, not necessarily an error. | Decide whether your downstream system expects the substitution. |
| CJK confusables | 未 vs 末, 己 vs
已 | One stroke apart. | Read names and addresses against the image. |
| Japanese small kana | っ → つ, ゃ →
や | Size distinction lost at low resolution. | Higher resolution; proofread kana-dependent words. |
| Korean jamo composition | Syllables split or recomposed incorrectly | Different Unicode composition paths. | Normalise to NFC before comparing, and check names. |
| Table reading order | Columns merged into one line | OCR returns text boxes, not a table model. | Don't rely on layout; extract fields individually. |
| Hyphenated line breaks | docu- / ment |
The line break is in the image. | Join and dehyphenate during normalisation. |
| Stamps over text | Words merged or dropped under a seal | Two ink layers at different contrast. | Rescan in colour; expect manual fixes in stamped areas. |
| Handwriting | Names and dates replaced by plausible nonsense | Models are trained mostly on print. | Treat handwritten fields as unread unless verified. |
That last row matters more than its position suggests. A wrong printed character usually looks wrong. A wrong handwritten word often looks plausible, which is worse, because nothing prompts you to check it.
What the result actually licenses you to do
A CER number doesn't have a universal pass mark. It has a pass mark for a job.
- Finding a page again. A few percent is tolerable. Search is forgiving; you only need enough of the right characters to hit the result.
- Reading prose. Low single digits is comfortable. You'll notice an occasional wrong word but the meaning survives.
- Copying an identifier. The bar is zero errors in that field. A 99.9% CER still means one wrong character in a thousand, and an IBAN or passport number with one wrong character is simply wrong.
- Extracting amounts and dates. Field-level checking beats CER. Count how many complete fields are exactly right, not how many characters are right.
This is why "searchable PDF" and "data extraction" are different products. A searchable PDF can be useful at 97% character accuracy because you're using it to find a page. A spreadsheet of invoice totals at 97% is a liability.
How ScanWisp's OCR is set up
ScanWisp ships 66 languages and marks six as verified: Chinese, English, Japanese, German, French and Korean. The rest are best-effort, and the language list says so instead of implying uniform quality. Models are grouped by script: German and French share the Latin model, Chinese, Japanese and English share the main CJK model, and Korean loads its own.
Two practical consequences for testing. First, choose the document's language explicitly; leaving it on the wrong model produces confident text with the wrong language assumptions, and across scripts it can return the wrong alphabet entirely, which is harder to spot than an empty result. Second, the first scan in a script group downloads its model, so exclude that run from any timing comparison. Recognition after that runs locally, and the searchable PDF explainer covers what the text layer actually contains.
We don't publish a single accuracy figure for the app, and this guide is the reason. The number would depend on your pages, your language and your lighting. The claim we can defend is narrower and more useful: the recognition runs on your device, and you can test the result yourself before trusting it.
If you're comparing two tools
Fair comparison is mostly about removing the ways the comparison can flatter one side.
- Use one set of source images. Same photos, same crops, same rotation, fed to both tools.
- Set the same language. If one tool auto-detects and the other doesn't, run the auto-detect tool twice and report both.
- Use the same normalisation. Same script, same rules, same whitespace handling.
- Score by category. One tool may win on clean print and lose on receipts; an average would erase that.
- Record time and offline behaviour. A tool that needs a network round trip per page behaves differently on a plane, and the difference is part of the product.
- Check what the export gives you. A TXT file and a PDF with a text layer are not the same artefact, and one may be easier to score than the other.
And be suspicious of tools that "clean up" the text with a language model after OCR. They can turn a misread word into a fluent one, which improves the reading experience and quietly invents content. Check numbers and names against the image, not against what the sentence ought to say.
Questions about OCR testing
What is a good character error rate?
There isn't a universal one. For search, a few percent is workable. For identifiers or money, the only acceptable rate in those fields is zero. Decide the job before you decide the threshold.
Why does OCR fail on handwriting?
Recognition models are trained mostly on printed glyphs. Handwriting varies by writer, speed and pen, so there's far less consistent signal to learn. Printed labels on a form usually read fine; the handwritten answers are the part to verify.
Why are numbers worse than words?
Context helps. A language model can guess that "reciept" means "receipt", but it can't guess whether a digit should be 3 or 8. Numbers have no redundancy, so every character has to be right on its own.
Do I need to write code to do this?
No. A spreadsheet with a character count and a manual edit count works for ten pages. The script just removes arithmetic mistakes and makes re-scoring after a settings change less tedious.
Can I compare the accuracy numbers vendors publish?
Only if they disclose the corpus, the language, the metric and the image conditions. Without those, the number is a mood, not a measurement.
Run the test on your own worst page. ScanWisp exports the recognised text as TXT, and a PDF can carry the same text as an invisible layer, so you can score the output with the method above. No account, no upload, and the model runs in the tab.
Scan a document