Skip to content
Creative Studio, runs on our GPU

Documents · 7 min read

Urdu and Arabic OCR: why Nastaliq defeats most tools, and how to get text you can use

Arabic-script letters change shape and join, many differ only by their dots, and Urdu print uses Nastaliq, a sloping, stacked style that standard OCR models were never trained on. Here is what to expect, measured, and how to get a clean result from a photo or a scan.

Saad Naeem

AI engineer, Doha · Updated

Why a tool that reads English perfectly makes a mess of Urdu

Optical character recognition has worked well on English print for twenty years. Point the same tool at a page of Urdu and the result is often a string of disconnected letters, question marks and words that never existed. The reasons are specific, and knowing them tells you what to expect and how to get usable text anyway.

The first is that Arabic-script letters change shape. Each letter has up to four forms depending on whether it stands alone, starts a word, sits in the middle or ends it, and letters join to their neighbours. English OCR learns 52 letter shapes; Arabic-script OCR has to learn several hundred, and has to decide where one letter stops and the next begins inside a continuous stroke.

The second is dots. Many Arabic and Urdu letters share a skeleton and differ only in the number and position of dots: ب, ت, ث, ن and ي all share one base shape. A speck of dust, a dropped dot in a cheap print or a slightly blurred photo changes the letter, and the word with it.

The third, and for Urdu the largest, is Nastaliq. Arabic is normally printed in Naskh, an upright style with letters sitting on a baseline. Urdu books, newspapers, notices and most official documents in Pakistan are set in Nastaliq, where words slope down from upper right to lower left, letters stack on top of each other, and the dots float well above and below the stroke they belong to. A line of Nastaliq has no baseline in the usual sense, and the standard OCR models, all trained on Naskh, read it badly.

We measured how badly. On the same sentences set in the two styles, the standard open-source Urdu model gets about 27 percent of characters and 74 percent of words wrong in Nastaliq, against a few percent in Naskh. Three words in four wrong is not a text you can correct; it is a text you retype.

A recogniser trained on Nastaliq

The Urdu OCR tool on this site does not use the standard model. It uses a recogniser we trained ourselves on tens of thousands of lines of printed Urdu, rendered in Nastaliq and Naskh typefaces from Urdu text, with the blur, tint, skew and noise of real photographs added. On pages it had never seen, it gets about 4 percent of characters wrong in Nastaliq print, and about 16 percent of words. On a turned, blurred phone photo of a page the figures are about 7 and 24 percent; on clean Naskh they fall to well under 1 and 2 percent. Those pages were set in the Nastaliq faces the recogniser learned from. Real text in a face it never saw reads less well: on screenshots of Urdu news articles set in Hussaini Nastaleeq, it got about 13 percent of characters and 43 percent of words wrong, where the standard model got 24 and 66 percent.

Those numbers are the honest frame for what follows. Four percent of characters means roughly one wrong letter every two lines: a text you proofread, not one you retype, and one where the tool can show you which words to look at. It also means that no OCR of Nastaliq, ours included, should be pasted into a legal document or a certificate without a human reading it first.

Try it: Urdu OCR

Each recognised line appears under a strip of the original, with doubtful words marked, so you can check the text against the picture line by line. Copy it, or download it as .txt or as a Word file set right to left in a Nastaliq font.

Open tool

For Arabic, the picture is simpler because Arabic print is Naskh: the Arabic OCR tool uses Tesseract’s Arabic model, which reads common printed fonts well, and the advice below about photographs and proofreading is what makes the difference between a clean result and a messy one.

How to photograph a page so OCR can read it

Most OCR failures are failures of the picture, not the model. A page photographed in a hurry, at an angle, under a ceiling light, can lose half its accuracy before any recognition happens. The same page shot carefully reads almost as well as a flatbed scan.

Problem What it does to the text What to do instead
Shot at an angle Lines converge, letters are squashed on one side; line detection fails Hold the phone flat above the page, parallel to it; use the Scan to PDF tool’s page detection to straighten it first
Shadow of the phone or hand A dark band the recogniser reads as ink Stand so the light comes from the side; daylight from a window is best
Glossy paper or a screen Glare wipes out letters Tilt slightly away from the light source, or photograph in diffuse light
Too far away Letters are a few pixels tall; dots vanish Fill the frame with the text you need; 30 pixels per line height is the minimum, 50 is comfortable
Curved pages near a book’s spine Text bends; stacked Nastaliq letters merge Press the page flat, or photograph one column at a time
Faded or coloured print Low contrast between ink and paper Turn off the flash, increase exposure slightly; the tool stretches contrast but cannot invent it

Two habits help more than any setting. Photograph one page, or one column, at a time: a two-column page shot whole makes the lines of the two columns run together. And check the picture before you run the OCR; if you cannot read a word on your own screen at full zoom, the recogniser cannot either.

Right-to-left: the problems that appear after recognition

Even a perfectly recognised Urdu or Arabic text can look wrong once it is on a screen, because of direction.

Text that reads backwards. Arabic script is written right to left, but digits, English words and most software default to left to right. A paragraph pasted into a left-to-right text box will show the words in the right order but the lines aligned to the wrong side, and a line that mixes Urdu with a phone number or an English name can have the mixed part jump to the wrong end. The fix is to set the paragraph direction to right-to-left in whatever you paste into: in Word, the right-to-left paragraph button; in Google Docs, the same under Format; in WhatsApp and most messaging apps it is automatic. The Word file the Urdu OCR tool downloads is already set right to left, with a Nastaliq font, so it opens correctly.

Letters that show disconnected. If a word appears as separate, unjoined letters, the application is missing a font that can shape Arabic script, or has been given each letter in its isolated form. Choose an Arabic or Urdu font (Noto Nastaliq Urdu, Jameel Noori Nastaleeq, Noto Naskh Arabic) and the joining returns.

Diacritics. Tashkeel, the small vowel marks in Arabic, are often dropped by OCR or read as dots and turned into other letters. Religious and classical texts carry them; most everyday print does not. If you need them, expect to add them by hand; if you do not, the Remove Tashkeel tool strips any stray ones from the result.

Proofreading in minutes, not hours

The difference between a usable OCR result and an unusable one is how quickly you can find the errors. Reading the whole text twice against the original is how people give up and retype.

The Urdu tool shows each recognised line directly under a strip of the original image, and marks words it is unsure about, either because the recogniser’s confidence was low or because the word is not in its list of about 26,000 Urdu words. Checking becomes a scan down the page for the marked words, a glance at the picture above each one, and a tap to correct it in place. Typical pages take a minute or two.

Three places deserve a second look even when nothing is marked: numbers, since a wrongly read digit is not a spelling error any list can catch; proper names, which are not in any word list; and the dotted letter pairs (ب and پ, ج and چ, د and ڈ, ر and ڑ), where a lost or added dot produces a real but wrong word.

For a scanned PDF rather than a photo, the PDF to Word tool runs the same recognition on every page it finds no text on, in English, Arabic or Urdu, and puts the result in an editable Word file; proofread it the same way.

What stays on your device

Everything above happens inside your browser. The recogniser, about 20 MB with its runtime, downloads once from this site and runs on your own processor; the photograph, the scan and the text it produces are never sent anywhere. For an ID card, a certificate or a private letter in Urdu, that is the point: once the recogniser has downloaded and read one image, you can switch off your internet connection and the OCR keeps working while the page stays open.

Frequently asked questions

Why does OCR read Urdu so badly?

Most Urdu print is set in Nastaliq, where words slope and letters stack, and the standard open-source Urdu model was trained on upright Naskh. On the same sentences it gets about 27% of characters and 74% of words wrong in Nastaliq. The Urdu OCR tool on this site uses a recogniser trained on Nastaliq, which gets about 4% of characters wrong on sentences it has never seen in the faces it learned, and about 13% on screenshots of real news in another Nastaliq face.

Can OCR read handwritten Urdu or Arabic?

Not reliably. The recognisers here were trained on printed text; handwriting, calligraphy and decorative headings produce many errors. Printed pages, notices, books and official letters are what they are for.

Why does the recognised Arabic text appear backwards or broken?

The text is right-to-left but was pasted into a left-to-right box, or the application lacks a font that joins Arabic letters. Set the paragraph direction to right-to-left and choose an Arabic or Urdu font. The Word file the Urdu OCR tool downloads is already set up this way.

How accurate does the photo need to be?

Hold the phone flat above the page, in daylight from the side, with the text filling the frame and letters at least about 30 pixels tall. Shadows, glare, angled shots and curved pages near a spine cause most errors. If you cannot read a word on your own screen, the OCR cannot either.

Is my document uploaded for OCR?

No. The recogniser (about 20 MB with its runtime) downloads once from this site and runs in your browser. The photo, the scan and the text stay on your device; once it has read one image, you can switch off your connection and it reads the next one without it.

Written by Saad Naeem

AI engineer in Doha who builds every tool on ToolboxHere. The figures in the guides come from the official sources named in them or from the tools themselves. Found a mistake? Tell us and it is corrected.

Found this guide useful?

Related guides