← Blog Life

How to Extract Text from Images with OCR

November 14, 2025 · 6 min read

A few months ago, a colleague handed me a stack of scanned contracts and asked if I could "just pull the text out real quick." Thirty pages of slightly tilted, low-resolution scans. That was the day I truly appreciated what OCR can and can't do, and learned the tricks to get the best results.

How OCR Actually Works

OCR stands for Optical Character Recognition, and the name is more literal than you might think. The software looks at an image, identifies shapes that resemble letters, and converts them into machine-readable text. Modern OCR engines don't just match shapes to a font table, though. They use neural networks trained on millions of text samples, which is why they can handle messy handwriting, unusual fonts, and even slightly damaged documents.

The process typically involves several stages. First, the image gets preprocessed: converted to grayscale, contrast-enhanced, and deskewed if the scan came through at an angle. Then the engine identifies text regions, segments them into lines and individual characters, and finally recognizes each character. Post-processing might apply spell-checking or language models to correct errors. All of this happens in seconds, which still feels a bit like magic to me.

Real-World Uses You Might Not Expect

The obvious use case is scanning paper documents, but OCR reaches much further than that. I've used it to extract text from screenshots of error messages that someone pasted into a chat as an image (we've all been there). Grabbing recipe text from a photo so I can save it in plain text has saved me more time than I'd like to admit.

Business cards are another great example. Instead of manually typing out someone's contact info, snap a photo and let OCR do the work. Receipts and invoices follow the same pattern. If you need to expense a pile of paper receipts, OCR can pull out vendor names, dates, and amounts far faster than manual entry.

Students and researchers use it to make scanned textbooks searchable. Historians digitize old manuscripts. Government agencies convert decades of paper records into searchable databases. The applications keep multiplying.

Getting Better Results from Your Images

OCR accuracy depends heavily on image quality, and there are practical steps you can take to improve results dramatically. I've found that the single biggest factor is resolution. Anything below 200 DPI tends to produce unreliable results. For clean printed text, 300 DPI is the sweet spot. Going higher doesn't usually help much and just makes the files bigger.

Lighting matters more than most people realize. Shadows across a page create dark bands that confuse the recognition engine. If you're photographing a document with your phone, try to get even lighting across the entire surface. Natural diffused light works well. Flash can cause glare on glossy paper, which is even worse than shadows.

Straighten the image before running OCR. A page photographed at an angle loses accuracy because the text lines aren't horizontal. Many OCR tools have built-in deskewing, but starting with a straight image gives you a head start. Cropping out everything except the text region also helps, because the engine won't waste processing power trying to interpret decorative borders or background patterns.

Handling Different Types of Content

Not all text is created equal from an OCR perspective. Clean, black-on-white printed text in a common font is the easiest scenario. Handwriting is much harder, though modern engines handle neat handwriting reasonably well. Stylized fonts, watermarked backgrounds, and colored text on colored backgrounds all reduce accuracy.

Tables and structured layouts present their own challenges. The OCR engine might recognize every character correctly but scramble the column alignment. In my experience, keeping the original image alongside the extracted text is always a good idea so you can verify the structure.

Browser-Based OCR: Privacy and Convenience

One thing that concerns people about online OCR tools is privacy, and rightfully so. Uploading sensitive documents to a server means trusting that server with your data. That's why browser-based OCR tools that process everything locally are worth paying attention to. The image never leaves your computer. The recognition runs entirely in your browser using JavaScript libraries like Tesseract.js.

The tradeoff is speed. Server-side OCR with powerful hardware is faster, especially on large batches. But for a handful of pages, the browser approach works perfectly and keeps your data under your control.

Final Thoughts

OCR has gone from a specialized technology to something we use casually every day. Your phone's camera app probably uses it when you point at a sign. Search engines use it to index text inside images. The key to getting good results is preparing your images well: high resolution, good lighting, straight alignment, and clean contrast. Get those right, and OCR will save you hours of tedious manual transcription.