Image ToolsOCR

Image to Text (OCR): The Complete Guide to Extracting Text from Photos, Scans, and Screenshots

Everything you need to know about optical character recognition — how it works under the hood, when to use it, how to get the best results, and why running it in your browser is the most private option available.

What is Optical Character Recognition (OCR)?

Optical Character Recognition — almost universally shortened to OCR — is the technology that converts an image containing text into actual, machine-readable characters. Before OCR existed, a scanned page was just a picture; you could look at it, but you could not search it, copy from it, or feed it into a word processor. OCR changed that by teaching computers to “read” pixels the way a human eye reads ink.

The concept dates back to the early 20th century, when engineers experimented with photoelectric cells and analog circuits to decode Morse code and teletype. By the 1960s, commercial OCR machines were being used by banks to read account numbers printed on cheques. Today, OCR runs in real time on smartphones, powers the Google Translate camera feature, indexes billions of scanned books, and — thanks to open-source engines like Tesseract — runs entirely inside a browser tab without sending a single byte to a server.

How OCR works at a high level

Modern OCR follows a pipeline with several distinct stages:

  1. Pre-processing. The engine adjusts the image before any character detection happens. Common steps include converting to greyscale, binarising (turning every pixel to either black or white based on a brightness threshold), deskewing (rotating slightly to straighten tilted lines), and denoising (removing speckles that might be mistaken for characters).
  2. Layout analysis. The engine segments the image into logical regions — headlines, columns, paragraphs, tables, images. This step ensures that characters from different columns are not mixed together and that the reading order matches what a human would naturally follow.
  3. Character segmentation. Within each text region, the engine isolates individual characters or clusters of characters (called glyphs). Because real-world fonts vary widely, this step has to deal with letters that touch each other, letters with gaps in them, and varying spacing.
  4. Recognition. Each segmented glyph is compared against a trained model. In older template-matching systems, the glyph was literally overlaid on stored character images and scored by similarity. In modern engines like Tesseract 4+, a long short-term memory (LSTM) neural network reads sequences of character features and predicts the most likely string of characters — a much more robust approach that generalises across fonts, sizes, and even languages.
  5. Post-processing. The raw character sequence is refined using a dictionary or language model. If the recognition engine produced “fhe” but “the” is far more common in English, the post-processor can correct the error. This is why OCR tends to perform better on well-written prose than on arbitrary strings of characters.

The sourcecodestack Image to Text tool uses Tesseract.js, the JavaScript port of Google’s open-source Tesseract engine, to run this entire pipeline directly in your browser. No server receives your image at any point.

Common Use Cases for OCR

OCR is one of those technologies that becomes indispensable once you realise how many everyday problems it solves. Here are the situations where people reach for it most often.

Digitising physical documents

Paper contracts, old invoices, printed reports, and archive materials all become searchable and editable the moment you run OCR on a scan or photo. A scanned bank statement that would otherwise require manual retyping can be converted to a spreadsheet-ready text file in seconds. Law firms, accountants, healthcare professionals, and anyone who handles large volumes of paper documents relies on OCR to make those files useful in digital workflows.

Extracting text from screenshots

Screenshots are everywhere — error messages in apps that do not allow copy-paste, terms-and-conditions dialogs that are rendered as images, social media posts you want to quote, code shown in a video tutorial. Instead of transcribing text by hand, you can drop the screenshot into an OCR tool and get the text out instantly. This use case alone saves an enormous amount of time for developers, researchers, and content creators.

Reading receipts and invoices

Expense reporting is tedious when it involves typing out amounts, dates, and vendor names from a pile of receipts. OCR can pull that data from a phone photo of a receipt and feed it directly into a spreadsheet or expense management app. Even if the formatting needs some tidying, getting the raw text out in one click is a significant time saver.

Business cards

Photographing a business card and running OCR on it gives you the name, title, phone number, email, and address as copyable text that you can paste directly into a contacts app. This workflow is faster and more accurate than manually typing the details, especially when the card uses small or decorative fonts.

Digitising notes and whiteboards

A photo of handwritten meeting notes or a whiteboard covered in bullet points can be processed with OCR to capture the content. Results vary depending on how neat the writing is, but printed block capitals and clear block writing often come through surprisingly well.

Accessibility

Images containing text are invisible to screen readers and search engines. OCR bridges that gap: text extracted from an image can be fed to a text-to-speech engine, added as an alt attribute, or stored as machine-readable metadata alongside the image. This matters both for users with visual impairments and for SEO.

Translating foreign-language images

If you have a photo of a menu, a sign, or a label in a language you do not read, OCR can extract the text as the first step in a translation workflow. Once the characters are in text form, any translation tool can handle the rest. The sourcecodestack OCR tool supports English, Spanish, French, German, Italian, and Portuguese out of the box — useful for all of the most widely spoken European languages.

Tips for Getting the Best OCR Accuracy

OCR is not magic — it performs dramatically better on some images than others. The factors below have the biggest impact on accuracy. Taking a moment to address them before you upload can be the difference between a clean result and a frustrating mess of misread characters.

Resolution: bigger is better, up to a point

The single most important factor is resolution. An image where each character is only a few pixels tall is inherently difficult for any recognition engine to read — there simply is not enough information in those pixels to resolve ambiguous shapes. As a rule of thumb:

  • 150 DPI is generally the minimum for acceptable results on standard body text.
  • 300 DPI is the sweet spot for most scanned documents and produces near-perfect output on clean printed text.
  • 600 DPI helps with very small text (footnotes, fine print) but adds little benefit for normal-sized type and increases processing time.

If you are photographing a document with a phone camera, stand close enough that the text fills most of the frame. A 12-megapixel phone photo of an A4 page taken from 30 cm is usually more than sufficient.

Contrast: dark text, light background

The binarisation step in OCR converts the image to black and white based on a brightness threshold. If the contrast between the text and the background is low — grey text on a white page, black text on a dark background, or coloured text on a similarly coloured background — characters can be lost or merged with the background during binarisation. For best results:

  • Ensure the text is noticeably darker than the background (or vice versa).
  • Avoid photographing documents under uneven lighting that creates shadows across the text area.
  • If you have control over the original document, use a plain white or light-coloured background and black or very dark ink.

Orientation: keep text straight and level

OCR engines handle slight skew well, but images where the text runs at a steep angle, is upside down, or wraps around a curved surface (like a book spine) will cause significant errors. If your image is rotated, use any image editor or even your phone’s built-in crop/rotate tool to straighten it before running OCR. Avoid photographing documents at an angle — lay them flat or prop them against a vertical surface and photograph straight on.

Avoiding blur and compression artifacts

Motion blur from a shaky hand, out-of-focus blur from poor autofocus, and block artifacts from heavy JPEG compression all degrade the fine detail that OCR needs to distinguish similar characters (l vs I vs 1, rn vs m, 0 vs O). When photographing a document:

  • Use a tripod or brace your elbows against a stable surface.
  • Tap to focus directly on the text before capturing the image.
  • Save the image in PNG format if possible — JPEG is fine, but avoid very high compression settings.

Margins and cropping

Including a small white border around the text (rather than cropping right to the edge of the characters) helps the layout analysis step correctly identify text regions. Most scanning apps add a small margin automatically; if you are cropping manually, leave a few millimetres of clear space around the text block.

Selecting the correct language

Tesseract uses language-specific dictionaries and character sets during post-processing. If the text in your image is in French but you run the engine in English mode, accented characters like é, à, and ç are more likely to be mis-recognised. Always choose the language that matches the text in your image. For multilingual documents, the best approach is to OCR language by language on separate passes.

Accuracy factors at a glance

FactorBest practiceWhat goes wrong without it
Resolution300 DPI or higherCharacters too small to resolve; high error rate
ContrastDark text on light backgroundCharacters merge with background after binarisation
OrientationText horizontal, image uncroppedLine segmentation fails; garbled output
SharpnessNo blur or focus issuesSimilar characters (l/I/1) confused
Language settingMatch to text languageAccents and special characters mis-recognised
File formatPNG or high-quality JPEGCompression artifacts degrade fine character detail

OCR Limitations You Should Know About

OCR is genuinely impressive on high-quality printed text, but there are categories of input where even the best engines struggle. Being aware of these limitations saves frustration.

Handwriting

Standard OCR engines are designed and trained for printed or typed text. Handwriting — especially cursive or informal script — involves variable letter shapes, connected strokes, and ambiguous ligatures that standard character segmentation cannot handle well. Dedicated handwriting recognition (technically called Intelligent Character Recognition, or ICR) is a distinct problem requiring different models. Tesseract in particular is not an ICR engine and will produce poor results on handwritten content. If you need to digitise handwritten notes at scale, dedicated ICR products or cloud services with handwriting-specific models are a better fit.

Stylised, decorative, and script fonts

Fonts that look beautiful in print can be nearly unreadable to an OCR engine: ornamental swashes, extreme serifs, overlapping letterforms, and artistic distortion all reduce accuracy. Logos, poster text, and greeting cards are typical examples. Even a human reader sometimes needs context to decode a highly stylised word, and an OCR engine has no visual context to fall back on.

Low-quality or heavily degraded images

A faded photocopy, a water-damaged document, or a photo taken in poor lighting can lose character detail to the point where even preprocessing cannot recover it. The OCR engine will still produce output, but with a high number of substitution errors. In these cases it is worth attempting to improve the source image — increasing contrast and brightness in an image editor before OCR can help meaningfully.

Complex layouts and mixed content

Dense tables with thin lines, multi-column layouts with irregular widths, text overlaid on photographs, and text running at angles around images all challenge the layout analysis stage. The OCR engine may identify the text correctly but assemble the words in the wrong order, breaking the logical structure. For complex layouts, you may need to crop the image into simpler sections and run OCR on each independently.

Numbers and special characters

While OCR handles most alphabetic characters well, numbers and punctuation that look similar are a frequent source of errors. Classic confusions include 0 (zero) vs O (letter O), 1 (one) vs l (lowercase L) vs I (uppercase i), and 5 vs S. When accuracy on numeric fields is critical — account numbers, phone numbers, dates — always proof-read the OCR output against the original image.

Browser-Based OCR and Privacy: Why It Matters

When you use a cloud OCR service, your image travels from your device over the internet to a remote server, where it is processed and the result is sent back. This workflow is convenient, but it means a third party has received a copy of your image. For many documents — identity cards, medical reports, bank statements, confidential business correspondence — that is an unacceptable tradeoff.

Browser-based OCR using Tesseract.js takes a fundamentally different approach. The recognition engine is compiled to WebAssembly and delivered as a JavaScript file. On your first visit, your browser downloads the engine and the language data once and caches them locally. Every subsequent OCR operation runs entirely on your own CPU, using memory your browser allocates locally. The image bytes never leave your device.

Why this architecture genuinely protects your documents

  • No server logs. If no server sees your image, no server can log, store, analyse, or accidentally expose it.
  • No account required. Because processing is local, there is no reason to identify you. No sign-up, no session, no tracking of what you scan.
  • Works offline after the first load. Once the engine and language data are cached, you can disconnect from the internet and continue scanning. This is useful when handling sensitive documents in environments where network activity is monitored.
  • Open-source and auditable. Tesseract.js is open source. Anyone who wants to verify that no data is being exfiltrated can read the source code.

You can verify this for yourself using your browser’s network panel. Open developer tools (F12), go to the Network tab, and run an OCR scan. After the initial engine download, you will see no outbound requests carrying your image data.

Browser OCR vs Cloud OCR: A Practical Comparison

Both approaches have legitimate uses. Here is an honest comparison to help you decide when each is appropriate.

When browser OCR is the right choice

  • The image contains sensitive personal, medical, financial, or legal information.
  • You need to process a moderate number of documents quickly without spending on API credits.
  • The image quality is good and the text is clearly printed — in these conditions browser OCR accuracy is competitive with cloud services.
  • You are working in a restricted network environment or on a connection with limited bandwidth after the initial engine download.
  • You want a zero-friction, no-account solution for ad-hoc scanning.

When cloud OCR has an edge

  • You are processing thousands of documents and need to parallelise at scale — cloud APIs can distribute workload across many servers.
  • The images are of poor or inconsistent quality and you need the most sophisticated pre-processing and model corrections available.
  • You need built-in features like table extraction, form field parsing, or document-type classification that go beyond raw text output.
  • You need accurate recognition for a language or script (Arabic, Chinese, Japanese, Hindi) that requires larger model files than Tesseract.js conveniently delivers in the browser.

For the vast majority of everyday OCR tasks — screenshots, receipts, printed documents, business cards — the browser-based Image to Text tool is all you need, and it handles them entirely on your device.

About Tesseract: The Engine Behind the Tool

Tesseract is one of the oldest and most battle-tested open-source OCR engines in existence. It was originally developed at Hewlett-Packard Laboratories in the mid-1980s, open-sourced in 2005, and has been maintained and improved by Google and a broad community of contributors ever since. Tesseract 4 introduced a deep-learning LSTM engine that dramatically improved accuracy over the earlier pattern-matching approach, particularly for documents with varied fonts and mixed languages.

Tesseract.js is a JavaScript/WebAssembly port of Tesseract maintained by the community. It compiles the core C++ engine to WebAssembly, allowing it to run at near-native speed in any modern browser without plugins, extensions, or server infrastructure. The language data files — which contain the trained neural network weights for each supported language — are downloaded on demand and cached by the browser’s cache storage, which is why the first scan takes longer than subsequent ones.

The sourcecodestack Image to Text (OCR) tool loads Tesseract.js on demand (only when you upload an image), so the engine does not slow down the initial page load. It shows live progress as recognition proceeds and produces editable text output that you can copy to your clipboard or download as a plain-text file.

Step-by-Step: Getting the Best Results from the Tool

  1. Prepare the image. If you are photographing a document, lay it flat on a well-lit surface and photograph straight down. Avoid shadows. If using a scanner, 300 DPI in PNG format is ideal.
  2. Choose the correct language from the dropdown before uploading. This primes the Tesseract language model for the character set and dictionary of the correct language.
  3. Upload the image by clicking the upload area. Supported formats include PNG, JPG, and WEBP. If your file is in another format, convert it first using any image editor.
  4. Wait for the progress indicator to reach 100%. Processing time depends on image size and your device’s CPU. A standard A4 page at 300 DPI typically takes 5–15 seconds on a modern desktop.
  5. Review the output in the text area on the right. For most clean documents, output will be accurate; spot-check numbers and any unusual characters against the original.
  6. Copy or download the extracted text. The Copy button puts the text on your clipboard for immediate pasting; the Download button saves a plain-text file named “extracted-text.txt”.

Frequently Asked Questions

Is this tool completely free?

Yes. There are no charges, no subscription tiers, and no usage limits. You can process as many images as you like without creating an account.

Why is the first scan slower than later ones?

On your first use, the browser downloads the Tesseract WebAssembly bundle and the language model for your selected language. These files are cached locally after the first download, so subsequent scans skip this step and are noticeably faster. If you change the language for the first time, there will be a short pause while the new language data file is fetched and cached.

Can I use this on a mobile phone?

Yes. The tool works on any modern mobile browser (Chrome for Android, Safari for iOS, Firefox for Android). You can photograph a document directly with your phone camera, then upload the photo. Mobile browsers support WebAssembly fully, so the OCR engine runs on your phone’s processor just as it would on a desktop.

What should I do if the accuracy is poor?

Work through the checklist in the accuracy section above. The most impactful fixes in order are: increase image resolution, improve lighting and contrast, straighten the image, and ensure the language setting matches the text. If the image quality is fundamentally poor (blurry, heavily shadowed, damaged), try adjusting it in an image editor before running OCR.

OCR accuracy depends entirely on input image quality. The tool produces its best results on clear, high-contrast, high-resolution images of printed text. Always verify important extracted data against the original source.