OCR

What is OCR and How Does It Work? A Complete Guide

9 min read

OCR turns a picture of words into words you can search and edit. Here is what actually happens between the image and the text, and why image quality decides everything.

Optical character recognition, universally shortened to OCR, is the technology that converts an image of text into machine-readable text. A photograph of a receipt, a scanned contract, a screenshot of an error message — OCR reads the shapes in the picture and produces characters you can search, copy, edit, and translate.

It feels like magic when it works and baffling when it does not. Both experiences make more sense once you know what the software is actually doing.

The problem OCR solves

To a computer, an image is a grid of coloured dots. There is no letter "A" anywhere in a photograph of the letter A — only pixels of varying darkness that a human brain interprets as a shape it has learned. OCR has to reconstruct that interpretation from scratch: find where text is, isolate individual characters, and decide which character each shape most likely represents.

How an OCR pipeline works

Modern engines vary in detail, but nearly all follow the same broad sequence of stages.

1. Pre-processing

The raw image is cleaned up before any recognition is attempted. This typically includes converting to greyscale, increasing contrast, removing noise and speckles, and binarisation — reducing every pixel to either black or white using an adaptive threshold so that uneven lighting does not swallow part of the page.

2. Deskewing and layout analysis

Scanned pages are rarely perfectly straight. The engine detects the dominant angle of text lines and rotates the image to level them. It then performs page segmentation: identifying which regions are text and which are images, tables, or rules, and determining reading order for multi-column layouts.

3. Line, word, and character segmentation

Within each text region, the engine finds horizontal bands corresponding to lines, then splits those into words using gap analysis, then into individual glyphs. This stage is harder than it sounds — touching letters, ligatures, and italic type all blur the boundaries.

4. Recognition

Each isolated glyph is classified. Older engines compared the shape against stored templates or measured geometric features such as loops, stems, and intersections. Contemporary engines, including the Tesseract engine used in modern browser OCR, use recurrent neural networks that process a whole line as a sequence rather than character by character, which handles context and proportional spacing far better.

5. Post-processing and language modelling

Raw classification output is then corrected using a dictionary and a statistical language model. This is why OCR reads "the" reliably even from a smudged scan: the engine knows which letter sequences are plausible in the target language. It is also why OCR on random serial numbers or unusual proper nouns is noticeably less accurate — there is no linguistic context to lean on.

What determines accuracy

OCR accuracy is not a fixed property of the software. It is overwhelmingly determined by the input.

  • Resolution. Text needs roughly 20 to 30 pixels of height per character to be recognised reliably. Scanning at 300 DPI is the long-standing standard for good reason.
  • Contrast. Dark text on a light background is ideal. Low-contrast grey-on-grey design, watermarks behind text, and coloured backgrounds all reduce accuracy.
  • Focus and motion blur. A phone photo taken slightly out of focus can be unreadable to OCR even when a human can still make out the words.
  • Typeface. Clean serif and sans-serif body faces perform best. Decorative, condensed, script, and heavily stylised faces perform much worse.
  • Skew and perspective. Photographing a page at an angle distorts letterforms; flattening the perspective first helps enormously.
  • Language and script. Accuracy depends on having the right language model loaded — running English models over French or Cyrillic text produces nonsense.

Handwriting is a separate problem entirely. Recognising handwriting is intelligent character recognition, or ICR, and even the best systems struggle with unconstrained cursive. Standard OCR should be expected to fail on handwritten notes.

Where OCR is genuinely useful

  • Making scanned archives searchable, so decades of paper records become queryable.
  • Extracting figures from invoices, receipts, and statements without retyping.
  • Copying text out of a screenshot, a slide photo, or an image-only PDF.
  • Digitising printed forms and questionnaires for analysis.
  • Accessibility — turning image-based documents into text a screen reader can voice.
  • Translating printed material by extracting text first, then translating it.

Getting the best results in practice

A few habits dramatically improve output quality. Capture at the highest resolution available rather than cropping in afterwards. Light the page evenly and avoid shadows from your own hands or phone. Shoot straight on, not at an angle. Crop tightly to the text region so the engine is not distracted by surrounding clutter. And if the source is a scanner, use 300 DPI greyscale rather than colour — it is cleaner and faster.

You can try all of this immediately with our Image to Text (OCR) tool, which runs the recognition engine entirely inside your browser. The image never leaves your device, which matters a great deal when the document is an invoice, a medical letter, or a contract.

If your source is a PDF rather than an image, convert the pages first with PDF to JPG, then run the resulting images through OCR. And if the captured image is rotated, straighten it with Rotate/Flip Image before recognition — a level baseline is one of the cheapest accuracy improvements available.

Realistic expectations

On a clean 300 DPI scan of printed body text, a good engine will exceed 98% character accuracy. On a hurried phone snapshot of a crumpled receipt under fluorescent light, 70% would be optimistic. OCR is a powerful accelerator, not a replacement for proofreading — always review extracted text before relying on it, particularly numbers, where a misread digit changes meaning entirely rather than merely looking odd.

Try the tools mentioned in this article

Every Convert26 tool runs entirely in your browser. Your files are never uploaded to a server.

Browse tools

Related reading