Skip to main content
How-To

How to Extract Data from Passports and IDs

Passports, driver's licenses, and national ID cards contain structured data in specific formats. OCR can extract this data for verification, record-keeping, and form-filling — but accuracy and privacy are critical concerns.

Published July 18, 2026 · 6 min read

Understanding the Machine Readable Zone (MRZ)

Most modern passports and ID cards include a Machine Readable Zone (MRZ) — two or three lines of text at the bottom of the data page using a standardized OCR-B font. The MRZ encodes the holder's name, document number, nationality, birth date, expiration date, and a check digit for verification.

MRZ text uses a fixed-width, monospace font designed specifically for machine reading. When the MRZ is clean and unobstructed, OCR accuracy can exceed 99%. However, stamps, visa stickers, and wear can partially obscure the MRZ, reducing accuracy.

Data Fields You Can Extract

FieldLocationAccuracy
Full nameData page + MRZ95%+
Document numberData page + MRZ98%+ (MRZ)
Date of birthData page + MRZ97%+ (MRZ)
Expiration dateData page + MRZ97%+ (MRZ)
NationalityMRZ96%+
PhotoData pageN/A (image)

Tips for Accurate Extraction

  1. Photograph flat and straight. Curved or angled shots distort the MRZ characters. Place the document on a flat surface.
  2. Use even lighting. Avoid glare from the laminated surface. Overhead lighting or diffused natural light works best.
  3. Include the full MRZ. Both lines (or all three for passports) must be fully visible. Cutoff MRZ lines cannot be reliably decoded.
  4. Resolve check digits. The MRZ includes built-in check digits that verify data integrity. Use these to validate extracted values.
  5. Handle multi-language names. Names in non-Latin scripts (Arabic, Chinese, etc.) appear in both native script and MRZ transliteration. Extract both versions.

Privacy Considerations

⚠️ Important: Handle ID Documents Carefully

  • • Passports and IDs contain highly sensitive personal data. Only process documents you own or have explicit authorization to process.
  • • Use tools that process data locally or in-memory without persistent storage. FastOCR does not store uploaded files after processing.
  • • Never share extracted ID data via unencrypted channels.
  • • Comply with local data protection regulations (GDPR, CCPA, etc.) when storing extracted identity data.
  • • Delete extracted data when it is no longer needed for its stated purpose.

Common Use Cases

  • • Auto-filling visa and immigration forms
  • • KYC (Know Your Customer) identity verification
  • • Digitizing personal records for backup
  • • Processing employee ID cards for access systems
  • • Extracting data from expired IDs for archival purposes

Extract ID Data — Free

FastOCR extracts text from passport and ID images. Files are processed in-memory and not stored. No registration required.