Skip to main content

Tesseract OCR — Open Source Text Recognition Engine

Tesseract OCR is a deep-learning engine designed to extract machine-readable text from images and PDFs. Use this documentation to master installation on Windows, Linux, and macOS, configure AI engine modes, and integrate OCR into your software pipelines.

Note: Tesseract core is a command-line program and C++ API library.
Instant Browser Demo: Don't want to set up local command-line binaries right now? Test image recognition instantly with our 100% private Online Web OCR Tool.

What is Tesseract?

Tesseract is an engine that takes raw image pixels and converts them into structured, searchable text data. Originating at Hewlett Packard in 1985, it is currently maintained by the global open source community and handles over 100 languages natively via deep learning Long Short-Term Memory (LSTM) neural networks.


Developer guides

Beyond this reference, we publish complete, tested guides for each Tesseract development task:

Installation

Tesseract installs in a single command on most systems. For the complete, tested walkthrough — Windows (UB Mannheim), macOS (Homebrew), Linux (apt / dnf / pacman / alpine), WSL2, Docker, Conda, language data and troubleshooting — see the dedicated installation guide.

→ Full Tesseract OCR installation guide


Quickstart & Basic CLI

Tesseract is fundamentally a command-line tool. Providing an image and determining a text output requires a single line.

Terminal
tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]

Example: Extract English Text

To extract text from invoice.png and save it to invoice_result.txt:

Terminal
tesseract invoice.png invoice_result -l eng
Note: Omit the .txt extension in the output base. Tesseract will automatically append .txt if printing standard text formatting.

Page Segmentation Modes (PSM)

Page Segmentation Modes (PSM) determine how Tesseract analyzes the layout of an image to find text blocks. By default, Tesseract expects a full page of text (PSM 3). If your input is a single word, a vertical column, or sparse text, you must declare the correct mode using the --psm flag.

Key Takeaway: Use PSM 3 (Auto) for general documents, PSM 6 (Single Block) for uniform text chunks, and PSM 7 (Single Line) for barcodes or labels.
  • 0: Orientation and script detection (OSD) only.
  • 1: Automatic page segmentation with OSD.
  • 3: Fully automatic page segmentation, but no OSD. *(Default)*
  • 4: Assume a single column of text of variable sizes.
  • 6: Assume a single uniform block of text.
  • 7: Treat the image as a single text line.
  • 11: Sparse text. Find as much text as possible in no particular order.
  • 13: Raw line. Treat the image as a single text line, bypassing hacks that are Tesseract-specific.

To force an assumed single line of characters:

Terminal
tesseract barcode.png stdout --psm 7

OCR Engine Modes (OEM)

OCR Engine Modes (OEM) switch between Tesseract's legacy pattern-matching engine and the modern LSTM neural network. You can toggle between these modes using the --oem flag to balance speed and recognition accuracy.

Key Takeaway: OEM 1 (LSTM) is the default for Tesseract 5 and provides the highest accuracy. OEM 0 (Legacy) is only recommended for specific fonts that pre-date neural network models.
  • 0: Legacy engine only. (Uses traditional computer vision parsing).
  • 1: Neural nets LSTM engine only. (Fast, highly accurate sequential memory parsing).
  • 2: Legacy + LSTM engines combined.
  • 3: Default, based on what is available in your .traineddata models.
Compatibility: Not all language packs support the legacy engine (OEM 0). The "fast" repo models only contain LSTM neural net data (OEM 1).

Output Formats

While extracting to raw stdout or .txt is common, Tesseract is a full document analyzer capable of emitting layout geometries and fully compliant PDFs.

Searchable PDFs

To convert an image to a bundled, searchable PDF where the recognized text is laid invisibly over the raw image:

Terminal
tesseract document.tif output_name pdf

Invisible Text Only PDF

Useful if you are overlaying text over existing PDFs inside an orchestration pipeline:

Terminal
tesseract scan.png output textonly_pdf

hOCR / TSV / ALTO

If you require data detailing the exact pixel bounding boxes of every single extracted word and its confident rating, use layout generation modes.

Terminal
tesseract input.png out hocr
tesseract input.png out tsv

→ Full Tesseract OCR PDF guide — searchable PDFs, OCRmyPDF, pdf2image and troubleshooting.


Programming Wrappers

Do you want to integrate Tesseract inside a web application or microservice? The open source community has built wrappers for nearly every language.

Python (pytesseract)

Install the engine, then pip install pytesseract pillow. The full guide covers image_to_string, image preprocessing, PDFs, confidence scores, PSM/OEM configuration and troubleshooting.

→ Full Tesseract OCR Python guide

Node.js JavaScript (tesseract.js)

Use tesseract.js in the browser or Node via WebAssembly. It recognises images and does not support PDFs. See the libraries reference for the full list of wrappers and trade-offs.

→ Tesseract OCR libraries & wrappers


Training Custom OCR Models

Tesseract 5 fine-tunes and trains LSTM models with the tesstrain project. Training is not available through the binary installers: you need a source build (or WSL2), plus make, ground-truth generation, and the tesstrain repository.

→ Full Tesseract training guide (tesstrain, fine-tuning, deployment)


Related Document AI & Deep Learning Engines

While Tesseract is the established open-source standard for text extraction, modern document pipelines often pair it with specialized neural engines:

  • PaddleOCR: A high-accuracy deep learning OCR engine (PP-OCR) providing advanced table recognition, layout analysis, and multi-language support. (guide)
  • Docling: An open-source document parser for GenAI & RAG that converts PDFs, images, and Office documents into clean, structured Markdown and JSON using pluggable OCR backends. (guide)
  • Python Pillow: The foundational image processing library in Python for contrast adjustment, thresholding, cropping, and format conversion before OCR execution.

End of Tesseract Core Documentation.

Disclaimer: TesseractOCR.org is an independent, community-driven documentation project and is not affiliated with, endorsed by, or connected to the official Tesseract OCR project or its maintainers.