By Greg Nowak. Last updated 2026-10-19.
Thai OCR can produce text that looks almost right while leaving awkward gaps, missing marks, or scrambled reading order. If your team is extracting text from scanned documents, those errors can turn a promising automation into another manual checking job.
Start with the correct Tesseract language model, match the settings to the page layout, and compare the output against the original. The preserve_interword_spaces option remains useful to test, but it needs a clearer explanation than the original short command example gave it.
Use the Thai language code: tha
For the standard Thai language model, use -l tha. The language file is tha.traineddata, as listed in Tesseract’s official model documentation. Replace the original example’s -l Thai with -l tha.
First, check the installed engine and available languages:
tesseract --version
tesseract --list-langsIf tha is missing, install the Thai language data using your platform’s package manager or place a compatible tha.traineddata file in its configured tessdata directory. The Tesseract command manual documents --tessdata-dir for specifying a different location.
For a full page, a straightforward starting command is:
tesseract image.png outfile -l tha --oem 1 --psm 3This writes the recognised text to outfile.txt. The input filename is an example; substitute your own image.
What does preserve_interword_spaces actually do?
The original article suggested enabling preserve_interword_spaces=1 to address odd spacing. Keep it as an experiment, rather than treating it as a universal Thai OCR fix.
Tesseract’s command-line guide demonstrates the option preserving wider gaps in a table of contents. It preserves detected interword spacing in text output; it does not promise to remove unwanted spaces or repair Thai word boundaries.
For a cropped, uniform block of text, compare these 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 baseline.txt and preserved.txt against the same image. Keeping the other settings identical makes it easier to judge whether preserving spaces helps your documents.
Thai generally uses spaces between phrases rather than individual words, as explained in the W3C’s draft Thai Script Resources. I would avoid a blanket cleanup rule that deletes every space: legitimate phrase breaks, English names, and reference numbers need attention too.
Match the layout setting to the document
A setting that works for a paragraph may fail on a complete form. Tesseract’s quality guidance recommends choosing a segmentation mode suited to the image region.
| Input layout | Starting setting | Check in the output |
|---|---|---|
| Complete document page | --psm 3 | Reading order and missing sections |
| One uniform text block | --psm 6 | Line breaks and unexpected gaps |
| One cropped text line | --psm 7 | Characters and marks retained |
| Scattered labels or short snippets | --psm 11 | Text found; reading order needs review |
For forms, consider processing clearly defined regions separately. A customer address and an item table may need different handling. Decide how those regions map to your destination system before building a batch process.
Improve the image before adding more settings
Check whether the original scan is sharp, straight, and evenly lit. Tesseract recommends images of at least 300 dpi and warns that skew can damage line recognition. Rescanning a poor original may be more productive than repeatedly changing OCR parameters.
Leave a small margin around cropped text. Compare any cleaned image with the original, especially around small marks above and below Thai characters. Aggressive noise removal can make a page look cleaner while removing details you need recognised. Change one preprocessing step at a time so you can tell which change helped.
Choose models by testing your own pages
The official model families include tessdata_fast and tessdata_best. The former prioritises speed; the latter trades processing speed for potentially better recognition. Both require the LSTM engine, selected with --oem 1, according to the official model documentation.
Test both if correction work is expensive. Record processing time alongside the errors a reviewer actually has to fix. For mixed Thai and English documents, also test -l tha+eng, with both language models installed. More languages should earn their place through better results on your sample.
Make the pilot useful to the business
Choose a small sample covering the documents your team really receives: clear scans, difficult scans, different templates, and mixed language pages. Ask a fluent Thai reader to check the text against the images.
Set acceptance criteria around the task. Searchable archives and automatic entry of invoice amounts have different consequences when recognition fails. Track incorrect characters, missing content, field accuracy, and review time separately. A document can look readable while still containing an incorrect reference number.
Keep the source image, raw OCR output, model identity, and command settings together. That gives operations staff and agency developers something reproducible when a new template performs poorly. Agree who reviews exceptions before connecting the output to a live workflow.
If you are assessing Thai OCR for an archive, document import, or internal process, talk to Greg about a focused pilot. Bring representative documents and explain where the extracted text needs to go; that provides a practical basis for deciding what to automate and where review belongs.
Related on GrN.dk
- Check version of pip installed python package CSVkit
- Drupal Wiki: Build a Knowledge Base People Can Actually Use
- From Supplier PDFs to Product Data: Where AI Needs a Second Check
Need help with this kind of work?
Discuss a Thai OCR pilot with Greg Get in touch with Greg.