Persian OCR (Farsi): seven free Tesseract runs, tested
86.6%
of letters, with Tesseract's fas best
fas best wins. Whole words lag.
We ran Tesseract 5.5.4 on 29 proofread pages from 10 printed books on fa.wikisource.
| Model | Letters | Words |
|---|---|---|
| fas best | 86.6% | 55.8% |
| fas, tessdata repo | 85.5% | 54.6% |
| fas | 85.4% | 54.8% |
| script/Arabic best | 84.8% | 52.7% |
| script/Arabic | 83.7% | 51.7% |
| fas+eng | 78.3% | 51.7% |
| ara (Arabic) | 72.3% | 29.3% |
fas best came first on 5 of 10 books.
It is slower: a median 3.3 s a page, against 1.7 s for fas.
Letters are proofread letters found in order. Words are whole words right, half spaces included.
The command: one model, one cleanup
curl -LO https://raw.githubusercontent.com/tesseract-ocr/tessdata_best/4.1.0/fas.traineddata
mkdir -p tessdata && mv fas.traineddata tessdata/
tesseract page.png page --tessdata-dir tessdata -l fas
perl -CSD -pi -e 'tr/\x{064A}\x{0649}\x{0643}/\x{06CC}\x{06CC}\x{06A9}/' page.txt
It writes page.txt. The last line turns Arabic ي and ك into Persian ی and ک, so a search finds them. With it: 86.9% of letters.
Homebrew's brew install tesseract-lang has the fast
fas. Use -l fas (85.4% here).
A near-empty page? Cut the edges
On one book, fas best wrote 12 words for a page of 359.
Cutting 4% off each edge took all three of its pages above 84%.
magick page.png -shave 4%x4% crop.png
tesseract crop.png crop --tessdata-dir tessdata -l fas
| Page | As scanned | Edges cut |
|---|---|---|
| 1 | 33.5% | 85.0% |
| 2 | 2.3% | 87.3% |
| 3 | 69.6% | 91.6% |
Cut only the pages that come back short. On the other 9 books, the cut cost 0.5 points.
The Arabic model lacks پ چ ژ گ
ara, the Arabic model, wrote none of the 948 پ, چ, ژ and گ on our pages.
It wrote Arabic ي, ى and ك 4,567 times. The proofread pages use Persian ی and ک.
The perl line fixes ي and ك: 72.3% becomes 81.9%. Nothing brings back the missing letters.
| Printed | این حیاط اندرون نگارستان است |
| fas best | این حیاط اندرون نگارستان است. |
| ara | اين حياط اندرون نكارستان است. |
| fas+eng | اين ble اندرون نگارستان است. |
Half spaces break word search
Persian puts a half space (U+200C) inside words such as میشود. fas best wrote 732 of them. The proofread pages have 314.
It also wrote fewer words, partly by running them together. Leaving out the near-empty book, it wrote 7,712 words where the proofread text has 8,552.
| Proofread | از لحاظ احتیاج و اضطراری |
| fas best | ازلحاظاحتیاجواضطراری |
If your search treats a half space as a space, 62.9% of words match whole.
A scanned PDF: keep the sidecar text
cp -r "$(brew --prefix)/share/tessdata/configs" tessdata/
TESSDATA_PREFIX=$PWD/tessdata ocrmypdf -l fas --jobs 2 \
--sidecar book.txt scan.pdf book.pdf
On a 29-page PDF of the same scans it took 53 s. book.txt held 86.5% of letters.
| From | Letters in order | Words |
|---|---|---|
| book.txt | 86.5% | 55.5% |
| book.pdf, pdftotext | 78.8% | 54.1% |
| book.pdf, PDFKit (Preview) | 44.8% | 55.3% |
The words are in the PDF, out of order. PDFKit gives one word a line, each line last word first.
The first line is for Homebrew. We ran it on a Mac. On Linux, copy
configs/ from your own tessdata folder. Skip it and OCRmyPDF stops
with
TesseractConfigError.
Two more things we checked
- fas+eng: our pages hold 28 Latin letters. On the 27 pages with none, it wrote 2,181. Use plain fas.
- Apple Vision on macOS 26.6 lists Arabic, not Persian.
How we ran it
- Pages marked proofread or validated on fa.wikisource, from a seeded shuffle of books, 3 a book (2 for one book). Pages with footnotes, tables or running heads in the text were left out.
- 27 pages came from PDFs, 2 from a DjVu file, 1,216 to 1,920 px wide. One book's scans show two pages side by side, and its proofread text covers both.
- Scores count Arabic-script letters, Persian ones included. Vowel marks, digits, punctuation, Latin letters and half spaces are left out.
- Models from tessdata_fast, tessdata_best and tessdata at tag 4.1.0. The tessdata repo's fas is a different file (561 KB), so we ran it too.
- One thread a run, 2 runs at a time, at low priority, while other jobs ran. Times are rough.
- OCRmyPDF 17.13.0, pdftotext from Poppler 26.03.0, PDFKit on macOS 26.6. The PDF holds the 29 scans as JPEGs, one a page.
- Licenses: Tesseract and tessdata are Apache-2.0, OCRmyPDF is MPL-2.0. All 10 scan files are on Commons, marked public domain. We show no page images.
Scanned pages to text, no install
Run it yourself. Our Apify Actor turns a scanned PDF into Markdown or text. $0.006 a scanned page. It reads 18 languages, Arabic but not Persian yet.
Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free. For Persian, ask first.
Questions people ask
Does Tesseract support Persian?
Yes, with the fas model. On our 29 pages, fas from tessdata_best read 86.6% of letters, the fast fas 85.4%.
Why does my Farsi OCR text have ي and ك?
ara, the Arabic model, wrote them 4,567 times on our pages, and fas best 166. Swap them with perl -CSD -pi -e 'tr/\x{064A}\x{0649}\x{0643}/\x{06CC}\x{06CC}\x{06A9}/' page.txt. ara also cannot write پ چ ژ گ.
Is there a free Persian OCR?
Tesseract and its models are free (Apache-2.0) and run offline. OCRmyPDF (MPL-2.0) adds a text layer to a scanned PDF.
Can I OCR a Persian PDF?
Yes. OCRmyPDF with -l fas and the fas best model found 86.5% of letters on our 29-page PDF. Take the text from --sidecar: macOS PDFKit (Preview) got 44.8% of letters in order from the PDF itself.
Why did Tesseract return almost nothing for my page?
On one of our books it read 2.3% of a page. Cutting 4% off each edge with magick page.png -shave 4%x4% crop.png took it to 87.3%.