Tesseract PSM and OEM Modes Reference for Invoice and Document OCR
Most poor Tesseract results on invoices come from the wrong page segmentation mode, not the engine. This reference lists every --psm and --oem value with the document types where each one tends to work.
| Flag | Value | Meaning | Best used for | Caution |
|---|---|---|---|---|
--psm | 0 | Orientation and script detection (OSD) only | Detecting rotation of scanned pages before real OCR | Produces no text output |
--psm | 1 | Automatic page segmentation with OSD | Mixed scan batches where pages may be rotated | Slower than mode 3; OSD needs the osd traineddata file |
--psm | 2 | Automatic page segmentation, no OSD or OCR | Not used in practice | Documented as not implemented |
--psm | 3 | Fully automatic page segmentation, no OSD (default) | Typical multi-block documents such as a full invoice page | Can merge a header table into running text |
--psm | 4 | Assume a single column of text of variable sizes | Receipts, delivery notes and narrow tickets | Side by side columns get interleaved |
--psm | 5 | Assume a single uniform block of vertically aligned text | Vertical text such as side margin stamps | Rarely right for normal AP documents |
--psm | 6 | Assume a single uniform block of text | Cropped regions such as a line item table or address block | Gives poor results on a whole page with several layouts |
--psm | 7 | Treat the image as a single text line | Cropped fields such as invoice number or date | Image must be tightly cropped to one line |
--psm | 8 | Treat the image as a single word | Short codes such as currency or unit of measure | Extra whitespace in the crop hurts accuracy |
--psm | 9 | Treat the image as a single word in a circle | Circular stamps and seals | Niche use |
--psm | 10 | Treat the image as a single character | Checkbox or single digit verification | Not for normal fields |
--psm | 11 | Sparse text: find as much text as possible in no particular order | Certificates, labels and forms with scattered fields | Reading order is not preserved, so rely on coordinates from tsv output |
--psm | 12 | Sparse text with OSD | Scattered text on pages that may be rotated | Needs the osd traineddata file |
--psm | 13 | Raw line: treat the image as a single text line, bypassing Tesseract-specific hacks | Pre-segmented line images from your own layout step | Use only when you control the cropping |
--oem | 0 | Legacy engine only | Only where legacy traineddata is installed and required | Not available in the standard fast or best LSTM data files |
--oem | 1 | Neural net LSTM engine only | Default choice for current traineddata on invoices and labels | Whitelists behave differently than with the legacy engine in older versions |
--oem | 2 | Legacy plus LSTM engines | Rare comparison testing | Needs legacy data and is slower |
--oem | 3 | Default, based on what is available | When you do not care which engine runs | Result can differ between machines with different language data |
Values reflect Tesseract 4 and 5 command line options. Run tesseract --help-psm and tesseract --help-oem on your build to confirm the list, since packaged builds vary.
Need OCR results posted to your ERP?
Optional: an expert can review your document types and suggest a private OCR and validation design.
Optional. The tool and every export work without this. No spam.
How to use this reference
Search by number, by document type or by phrase such as sparse or single line. Start with the full page mode (3) to see how Tesseract divides the page, then switch to a narrower mode once you have cropped a field. Keep the --oem value fixed at 1 for tests so that only one variable changes at a time. Export the table to Excel if you want to add your own column of measured accuracy per mode for your own supplier documents.
Choosing a mode for AP and quality documents
A typical supplier invoice has a header block, a line table and totals, so mode 3 usually segments it acceptably, while mode 6 works well when you have already cropped the table. Certificates of conformance and packing labels hold scattered fields, where mode 11 finds more text than mode 3. For one field crops such as an invoice number, mode 7 is the standard choice.
- Full invoice page: 3, then 11 if fields are missed
- Cropped line table: 6
- Single field crop: 7 (or 8 for one token)
- Scattered label or certificate: 11
- Mixed rotation batch: 1 or 12
Reading results with tsv output
Modes 11 and 12 do not preserve reading order, so do not rely on plain text. Ask for tsv output and group words by their left, top, width and height columns, then use the confidence column (conf) to flag low confidence words for human review. Tsv also lets you rebuild lines yourself, which is how most field extraction logic for ERP posting is built on top of Tesseract.
Common mistakes
Using mode 7 on an uncropped page returns garbage, because the engine expects one line. Running at the wrong resolution is another frequent cause of error: Tesseract works best when text height is roughly 20 to 30 pixels, which is often reached by scanning at 300 dpi. Finally, skipping the traineddata for the right language gives poor results on accented supplier names and addresses.
Frequently Asked Questions
Which Tesseract PSM mode is best for invoices?
Mode 3 (fully automatic, the default) is the usual starting point for a whole invoice page. If fields are missed on layouts with scattered boxes, try 11. For a cropped table use 6, and for single fields use 7. Measure on a sample of your own supplier documents.
What is the difference between psm 6 and psm 4?
Mode 6 assumes one uniform block of text, such as a cropped table or paragraph. Mode 4 assumes a single column of text of variable sizes, which suits receipts and tickets with headings and body text mixed. Neither handles side by side columns on a full page well.
Does --oem 1 work with any traineddata?
OEM 1 uses the LSTM engine and works with the standard LSTM-based traineddata files, including the fast and best variants. OEM 0 and 2 need data files that still contain the legacy engine model, which many downloads do not include.
Why is the order of text wrong in sparse mode?
Sparse text modes (11 and 12) find text wherever it is, without assuming a reading order. To reconstruct lines, request tsv output and sort words by their top and left coordinates, grouping by a vertical tolerance based on text height.
If you want OCR output turned into validated supplier invoice or inspection records in your ERP, Netray can build a private pipeline that runs on your own servers.
Related Tools
Tesseract OCR Command Line Generator
Build the exact tesseract command for a single file and a PowerShell loop for a whole folder, with language, page segmentation mode, resolution and output format set from a form.
Quality & InspectionOCR Confusable Characters Reference for AP Validation
A lookup of look-alike characters (0 and O, 1 and l, 5 and S and more) with the fields where they cause errors and a validation rule for each.
Developer ToolsInvoice Field Regex Generator (Python)
Set the labels your suppliers use and get a Python script with regexes for invoice number, PO number, invoice date and total amount, plus a total check.
AI Agents & AutomationDocument AI and OCR Pilot Readiness Checklist
A practical checklist covering sample selection, ground truth labeling, success metrics, security and ERP posting before you start an OCR or document AI pilot.
More Developer Tools tools
See all- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton
- ABAP Custom Exception Class Generator
- ABAP Unit Test Class Generator