By Greg Nowak. Updated 20 November 2026.
Thai OCR can look convincing until someone tries to use the text. Unexpected spaces break a search, a missing tone mark changes a word, or an amount ends up beside the wrong invoice line. For a business processing documents, the useful question is how much checking remains after recognition.
Tesseract provides a practical starting point, but there is no single setting that fixes Thai spacing. Start with the correct language model, match recognition to the document layout, and test the output against the task your team needs to complete.
Start with the Thai language code: tha
Tesseract’s Thai language code is tha, and its model file is tha.traineddata. Check your installation before experimenting with recognition settings:
tesseract --version
tesseract --list-langsIf tha is missing, install the Thai language data through your platform’s package manager or supply a compatible model in your tessdata directory. The official command manual documents --tessdata-dir PATH for selecting that directory.
For a complete page, establish a baseline:
tesseract image.png baseline -l tha --oem 1 --psm 3Replace image.png with your input image. This writes recognised text to baseline.txt. The command explicitly selects the LSTM recognition engine and automatic page segmentation without orientation detection. Rotate a sideways page before using this setup.
What preserve_interword_spaces actually changes
The setting preserve_interword_spaces=1 preserves detected spacing in text output. Tesseract’s command-line guide demonstrates it retaining wide gaps between headings and page numbers in a table of contents. It does not promise to remove unwanted spaces or identify correct Thai word boundaries.
For a cropped paragraph or another uniform text block, compare two runs:
tesseract image.png baseline -l tha --oem 1 --psm 6
tesseract image.png preserved -l tha --oem 1 --psm 6 -c preserve_interword_spaces=1Compare both files with the source image. Keep the model, image, and segmentation mode identical so you can isolate the spacing option’s effect. If wider gaps help someone read the output, keep it for that use. If they complicate importing the text into another system, leave it off.
Keep Thai spacing separate from word segmentation
Thai generally separates phrases with spaces rather than putting a space between every word, as described in the W3C’s draft Thai Script Resources. Missing English-style word spaces therefore does not automatically mean recognition has failed.
I would avoid a cleanup rule that deletes every space. A document may contain legitimate phrase breaks, English company names, dates, and reference numbers. Preserve the raw OCR text and apply any cleanup to a separate copy, with rules tested by a fluent Thai reader.
If your search or analysis system needs individual Thai words, treat word segmentation as a separate processing step. Test the result in the destination system: readable text alone does not establish that search, matching, or field extraction works.
Choose the layout setting before tuning characters
Use the page segmentation modes in the command manual as starting points. A setting suited to one cropped line is a poor assumption for a page containing several columns.
| Input | Starting mode | What to check |
|---|---|---|
| Complete page | --psm 3 |
Reading order and omitted sections |
| Uniform text block | --psm 6 |
Line breaks and unexpected gaps |
| Single cropped line | --psm 7 |
Characters, vowels, and tone marks |
| Scattered labels | --psm 11 |
Text coverage; ordering is not guaranteed |
Forms and tables need particular care. Tesseract’s quality guidance warns that table recognition can require custom segmentation or layout analysis. Preserved spaces do not establish which amount belongs to which item. For stable templates, test addresses, identifiers, and table regions separately, with explicit rules for mapping them into destination fields.
Improve the scan, then compare models
Tesseract’s quality guidance recommends images of at least 300 dpi and explains how skew harms line segmentation. Check sharpness, rotation, uneven lighting, and crop margins before adding more recognition settings. Changing a resolution label cannot restore missing detail.
When cleaning images, inspect the small marks above and below Thai characters. A visually tidier page is not necessarily a better recognition input. Keep the original and change one preprocessing step at a time.
The official model documentation distinguishes tessdata_fast from the slower tessdata_best. Both support the LSTM engine used by --oem 1. Compare them on your documents if correction work is expensive; the model name alone cannot tell you which workflow costs less.
For mixed Thai and English pages, also test -l tha+eng with both models installed. Tesseract documents that language order can affect output and runtime, so record the exact combination you use.
Judge the pilot by correction work
Build a sample containing clear scans, difficult originals, different templates, and mixed language pages. Have a fluent Thai reader check the output against the images. Record spacing errors separately from incorrect characters, missing content, and misplaced fields; those problems need different remedies.
Set acceptance criteria around the business task. An archive may need reliable search and access to the original page. Invoice processing needs checks on amounts, identifiers, and their relationships. Measure review time alongside recognition speed, and agree who handles exceptions.
Keep each source image, raw output, model identity, preprocessing steps, and command settings together. Give the agency or operations team a reproducible example when something fails. The pilot should end with a clear decision about which documents can proceed automatically and which require review.
If you are assessing Thai OCR for an archive, document import, or internal workflow, talk to Greg about a focused pilot. Bring representative documents and explain where the text needs to go. That gives us a practical basis for testing recognition, estimating correction work, and deciding what is worth automating.
Related on GrN.dk
- AI Invoice Processing: Catch the Errors Before They Reach Your Books
- Before an AI Assistant Issues a Refund, Put Approval in Its Path
- Prompt Cache Write Costs: Check What Your Workflow Actually Reuses
Need help with this kind of work?
Discuss a Thai OCR pilot with Greg Get in touch with Greg.