Skip to main content
Q&A Guide

How Do I Extract Text from Passports?

How do I extract text from passports? Learn about ICAO standards, MRZ reading, passport OCR, and how to digitize passport information.

Drop your file here

PDF, PNG, JPG, WebP, BMP

Direct Answer
To extract text from passports, photograph the data page and upload it to FastOCR at fastocr.org/image-to-text. FastOCR recognizes the passport holder's name, nationality, date of birth, passport number, and expiry date from clear passport photos. The Machine Readable Zone (MRZ) at the bottom of the data page contains encoded information that can be cross-verified against the visual text.

Passport Structure and OCR

Modern passports follow ICAO Document 9303 standards, which define the layout and data fields for machine-readable travel documents.

The Data Page Every passport has a data page containing: - Personal details: Full name, nationality, date of birth, sex - Document details: Passport number, issue date, expiry date, issuing authority - Photograph: Biometric photo of the holder - Machine Readable Zone (MRZ): Two or three lines of encoded text at the bottom

The Machine Readable Zone (MRZ) The MRZ is a standardized text block at the bottom of the data page. It uses a fixed-width font (OCR-B) and follows a strict format:

For a passport (Type P), the MRZ has two lines of 44 characters each: - Line 1: Document type, country code, name, passport number, checksums - Line 2: Passport number, nationality, birth date, sex, expiry date, checksums

The MRZ is designed specifically for OCR reading, so it is usually easier to read than the visual text fields above it.

Accuracy by Passport Type

Passport ElementVisual Text OCRMRZ OCR
NameCheck spellingStandardized font
Passport numberCheck digitsStandardized font
NationalityUsually clearStandardized font
Date of birthCheck digitsStandardized font
Expiry dateCheck digitsStandardized font
Issue dateCheck digitsNot in the MRZ
Place of birthCheck spellingNot in the MRZ

Tips for Passport OCR

  1. Photograph the data page flat — open the passport fully and press it against a flat surface
  2. Avoid glare on the laminate — the data page has a protective laminate that reflects light. Use indirect lighting or slightly angle the light source.
  3. Capture the entire page — include all four corners so the engine can detect the MRZ boundaries
  4. Use even lighting — avoid shadows from the passport cover or your hands
  5. 300 DPI minimum — passport fonts are small and need adequate resolution
  6. Select the correct language — passports use the issuing country's language plus English/French

Security and Privacy Considerations

Passport data is highly sensitive personal information. When using OCR on passports:

  • Process locally when possible — FastOCR does not store uploaded documents permanently
  • Delete extracted data after use — don't keep passport text on shared devices
  • Use for legitimate purposes only — passport OCR should be used for personal record-keeping, visa applications, or hotel check-ins — not for identity fraud
  • Verify extracted data — always cross-check OCR output against the original passport for critical applications

Frequently Asked Questions

Can FastOCR read the MRZ code on passports?

Yes. FastOCR extracts the Machine Readable Zone text at the bottom of passport data pages. The MRZ uses a standardized OCR-friendly font that is easier to read than the visual text.

How accurate is passport OCR?

The MRZ is easier to read than the visual text because of its standardized OCR-B font and fixed layout. Accuracy still depends on photo quality. Always verify extracted data against the original.

Can FastOCR read expired passports?

Yes. FastOCR extracts text from any passport regardless of expiry status. The MRZ remains readable as long as the physical page is in good condition.

Is it safe to upload passport images to FastOCR?

FastOCR processes documents without persistent external storage. Images are processed and returned without being stored on external servers. Always exercise caution with sensitive personal documents.