Skip to main content
Didit Raises $7.5M to Build the Infrastructure for Identity and Fraud
Didit
Back to blog
Blog · March 15, 2026

MRZ Parsing: A Deep Dive for Developers

Learn how Machine Readable Zone (MRZ) parsing works, its importance in identity verification, and how to implement it securely. We cover standards, data extraction, and best practices.

By DiditUpdated
mrz-parsing-developers-guide.png

MRZ Parsing: A Deep Dive for Developers

In the world of digital identity, verifying a user's identity is paramount. A crucial component of this process is MRZ parsing, or Machine Readable Zone parsing. This technology allows for the automated extraction of data from the machine-readable zone found on identity documents like passports, driver's licenses, and national ID cards. This article provides a comprehensive guide for developers looking to understand and implement MRZ parsing for robust identity verification technology.

Key Takeaways

What is MRZ? The Machine Readable Zone is a standardized area on identity documents containing encoded data.

Standards Matter MRZ data is encoded according to ICAO Document 9303, with variations like TD3 and TD1.

Data Extraction & Validation Parsing involves decoding the MRZ string, validating checksums, and extracting relevant fields.

Security is Critical Implement robust validation and error handling to prevent fraudulent data entry or manipulation.

Understanding the Machine Readable Zone (MRZ)

The Machine Readable Zone (MRZ) is a standardized area on identity documents designed for automated data extraction. Introduced by the International Civil Aviation Organization (ICAO), it facilitates quick and accurate identity verification at border control and other points of identification. The MRZ is typically located at the bottom of the document and consists of two or three lines of alphanumeric characters. This data is encoded according to specific formats, allowing machines to read and interpret the information without manual intervention.

ICAO Document 9303 and MRZ Standards

The foundation of MRZ parsing lies in ICAO Document 9303, which defines the standards for machine-readable travel documents. This document outlines two primary MRZ types:

  • TD3 (Two-Dimensional Three-Line): Commonly found on newer passports and ID cards. It utilizes a checksum for each line, enhancing data integrity.
  • TD1 (Two-Dimensional One-Line): Often seen on older documents. It's simpler in structure but still relies on checksum validation.

Each line within the MRZ contains specific data fields, separated by specific characters. Understanding the layout and meaning of each field is crucial for accurate parsing. For example, the first two characters of a TD3 line usually indicate the document type, followed by the issuing state, document number, nationality, date of birth, sex, and expiry date. The checksums are calculated using a specific algorithm defined in ICAO Document 9303.

The MRZ Parsing Process: A Technical Breakdown

MRZ parsing involves a series of steps to extract and validate data. Here’s a detailed look:

  1. Data Capture: The process begins with capturing an image of the MRZ using a camera or scanner.
  2. Line Detection: Identifying the lines constituting the MRZ within the image.
  3. Optical Character Recognition (OCR): Converting the image of the MRZ lines into a text string. The accuracy of OCR is paramount.
  4. Checksum Validation: This is a critical step. The checksum algorithm, as defined in ICAO Document 9303, is applied to each line. If the calculated checksum doesn’t match the checksum in the MRZ string, it indicates data corruption or tampering.
  5. Data Decoding: Interpreting the characters based on the MRZ standard (TD1 or TD3) and extracting specific fields (name, date of birth, document number, etc.).
  6. Data Formatting: Converting the extracted data into a standardized format (e.g., ISO 8601 for dates).

A correct implementation of ID document parsing requires understanding the specifics of each field and handling potential errors gracefully. For example, date formats can vary, and some fields might be optional.

Challenges and Best Practices in MRZ Parsing

Implementing robust MRZ parsing isn't without its challenges:

  • Image Quality: Poor image quality (blur, low resolution, distortion) can significantly impact OCR accuracy.
  • Document Variations: Different countries have different document layouts and font styles.
  • Security Concerns: Malicious actors might attempt to manipulate the MRZ data.

Here are some best practices to mitigate these challenges:

  • Use a High-Quality OCR Engine: Invest in a robust OCR engine specifically designed for MRZ recognition.
  • Implement Rigorous Validation: Validate the extracted data against known patterns and ranges. For instance, verify that the date of birth is a valid date.
  • Checksum Verification: Always perform checksum verification to ensure data integrity.
  • Error Handling: Implement comprehensive error handling to gracefully manage parsing failures.
  • Regular Updates: Stay updated with the latest ICAO Document 9303 revisions and adapt your parsing logic accordingly.

How Didit Helps

Didit simplifies MRZ parsing and identity verification technology for developers. Our platform provides a robust and accurate MRZ parsing module as part of our comprehensive identity verification suite. We handle the complexities of OCR, checksum validation, and data extraction, allowing you to focus on building your application. Didit’s API offers:

  • High Accuracy: Our OCR engine is optimized for MRZ recognition, delivering industry-leading accuracy.
  • Global Support: We support a wide range of document types from countries worldwide.
  • Security: Our platform incorporates robust security measures to protect against fraud and data manipulation.
  • Ease of Integration: Integrate MRZ parsing into your application with a simple API call.

Ready to Get Started?

Ready to streamline your identity verification process with reliable MRZ parsing? Request a demo or explore our documentation to learn more about integrating Didit’s identity verification solutions into your application. Start building secure and trustworthy experiences today!

Infrastructure for identity and fraud.

One API for KYC, KYB, Transaction Monitoring, and Wallet Screening. Integrate in 5 minutes.

Ask an AI to summarise this page
MRZ Parsing: A Developer's Guide.