ID document OCR is the automated reading of identity documents such as passports, national ID cards, residence permits and driving licenses, turning a photo or scan into structured fields like name, date of birth, document number and expiry date. Within Document AI, it is a specialized form of key information extraction that combines document detection, image correction, optical character recognition and field validation.
The technique is also known as identity document extraction, and its most standardized part is MRZ reading, the decoding of the machine-readable zone printed on travel documents. It underpins remote customer onboarding, know-your-customer checks, border control, hotel check-in and age verification, where speed must be balanced against accuracy and fraud resistance.
How ID document OCR processes an image
ID document OCR runs as a multi-stage pipeline in which each step reduces uncertainty for the next. Errors early in the chain, such as a poorly cropped card, propagate into every later field, so capture quality is often the decisive factor.
The table below lists the typical stages and their purpose.
| Stage | Purpose | Typical technique |
|---|---|---|
| Document detection | Locate the card or page in the frame | Object detection or corner regression |
| Geometric correction | Remove perspective and rotation | Homography, deskewing, dewarping |
| Document classification | Identify country, type and version | Image classifier over template library |
| Field localization | Find each data zone on the layout | Template zones or layout-aware models |
| Text recognition | Convert field images into characters | CRNN or transformer-based OCR |
| Validation | Check consistency and plausibility | Check digits, date logic, cross-field rules |
Classification is what separates ID document OCR from generic OCR. Once the system knows it sees, for example, a specific national ID card issued after a given year, it can apply a known layout, expected fonts and field formats, which raises accuracy far above template-free extraction.
The machine-readable zone and ICAO 9303
The machine-readable zone (MRZ) is a block of text in the OCR-B font at the bottom of the data page, defined by the ICAO Document 9303 standard. It encodes the core identity data in a fixed structure with check digits that allow software to detect misreads.
Three formats are in common use, and they differ in line count and line length.
| Format | Lines and characters | Typical document |
|---|---|---|
| TD1 | 3 lines of 30 characters | ID cards and residence permits |
| TD2 | 2 lines of 36 characters | Older ID cards and some visas |
| TD3 | 2 lines of 44 characters | Passports |
| MRV-A and MRV-B | 2 lines of 44 or 36 characters | Machine-readable visas |
Check digits use a weighted modulo 10 scheme with weights 7, 3 and 1. A single misread character in the document number, birth date or expiry date almost always breaks the corresponding check digit, which makes MRZ reading far more reliable than reading free-form visual fields. Names in the MRZ are transliterated and truncated, however, so the visual zone remains necessary for the exact spelling with diacritics.
Visual inspection zone and chip data
The visual inspection zone (VIZ) contains the human-readable fields, often in several scripts and languages. Reading it requires handling guilloche backgrounds, holograms, varied fonts and non-Latin alphabets, which makes it the hardest part of the document for OCR.
Robust systems cross-check VIZ against MRZ: the document number, birth date and expiry date must match after normalization. A mismatch indicates either an OCR error or a tampered document, and the system flags it for review rather than silently choosing one value.
Many modern documents also carry an NFC chip with the same data and a facial image, signed by the issuing state. OCR of the MRZ supplies the access key for Basic Access Control, after which the chip data can be read and its digital signature verified, which is stronger evidence of authenticity than any image analysis.
Accuracy, quality metrics and failure modes
Accuracy is best measured per field and per document type, not as a single global number. Useful metrics include character error rate, field-level exact match and the share of documents processed without human intervention.
The following table maps frequent problems to their causes and remedies.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Unreadable fields | Glare from laminate or hologram | Guide user to tilt card, use multi-frame capture |
| Wrong characters in names | Diacritics or non-Latin script | Script-specific recognition models |
| Swapped day and month | Country-specific date formats | Template-driven date parsing |
| Failed MRZ check digit | Blur or low resolution | Reject frame and recapture |
| Unknown document type | New issue or rare country | Fallback to manual review, update library |
Confusable characters such as O and 0, I and 1, or B and 8 are a classic error source. MRZ rules help here because certain positions accept only digits, and field-specific character sets should be enforced in the visual zone as well.
ID document OCR in verification workflows
ID document OCR is rarely used alone; it is one component of identity verification. Extracted data feeds sanctions screening, age checks and account creation, while separate modules handle document liveness, tamper detection and face matching against a selfie.
- OCR is not authentication: correctly reading a forged card produces correct-looking data from a fake document.
- Data protection rules apply: identity data is personal data, so retention, encryption and access must follow regulations such as the GDPR.
- Human review remains necessary for low-confidence fields and for document types outside the template library.
- Bias testing matters: accuracy should be checked across countries, scripts and capture devices, not only on the most common documents.
Recent vision-language models can read unfamiliar documents without templates, but they may hallucinate plausible values. In regulated settings they are best used alongside deterministic validation and extraction confidence scores.
The idea in brief
ID document OCR lets a computer read an ID card or passport from a photo. It finds the card, straightens the image and reads each line of text. The result is a neat set of fields like name and birth date.
Passports have special lines of code at the bottom. These lines include small math checks. If one letter is misread, the check fails and the system asks for a better photo.
A practical scenario
A digital bank opens accounts entirely through its mobile app. New customers photograph their passport or national ID card, and the bank must extract their data, verify the document and finish onboarding in under five minutes.
The app guides the user to hold the card flat, detects glare in real time and captures several frames. ID document OCR reads the MRZ, validates all check digits and compares the document number and dates with the visual zone. For passports with a chip, the MRZ data unlocks the NFC chip, and the signed chip data confirms authenticity.
About 90 percent of applications pass automatically. The rest, mostly worn cards or rare document types, go to a review team with the uncertain fields highlighted. Manual data entry disappears for most customers, and typing errors in customer records drop sharply.