Feb 25, 2026 · 5 min read

The Ultimate Guide to MRZ: Understanding TD1, TD2, and TD3

Learn how Machine Readable Zones (MRZ) work, the differences between TD1, TD2, and TD3 formats, and how to automate data extraction.

In the world of international travel and identity verification, the Machine Readable Zone (MRZ) is the gold standard. Whether you are building a check-in app, a fintech onboarding flow, or an automated border control system, understanding how to parse these characters is essential.

In this guide, we will break down the different types of Machine Readable Passports (MRP) and ID documents, their internal structures, and the best tools to extract this data—including how Tiny IDP can simplify your OCR workflow.

What is an MRZ?

The MRZ is a fixed-width area located at the bottom of identity documents, standardized by ICAO Doc 9303. It uses a specific OCR-B font to ensure that machines can reliably read data regardless of the document’s visual design.

There are three primary formats used globally:

  • TD1 (Size 1): Typically used for ID cards (like the EU identity card). It consists of three lines of 30 characters each.
  • TD2 (Size 2): Used for larger ID cards and some visas. It consists of two lines of 36 characters each.
  • TD3 (Size 3): The standard for passports. It consists of two lines of 44 characters each.

TD1: The ID Card Standard

TD1 MRZ Example

The TD1 format is the most compact and is frequently found on national identity cards and driver’s licenses.

Documents using TD1: EU Identity Cards, US Resident Alien cards.

TD1 Structure (3 Lines x 30 Characters)

LinePositionsFieldCheck Digit
11–2Document code (e.g., ID, IP)No
13–5Issuing State or organization (ISO 3166-1 alpha-3)No
16–14Document numberYes (Pos 15)
116–30Optional data (often empty or application-specific)No
21–6Date of birth (YYMMDD)Yes (Pos 7)
28Sex (M, F, or < for unspecified)No
29–14Date of expiry (YYMMDD)Yes (Pos 15)
216–18Nationality (ISO 3166-1 alpha-3)No
219–29Optional dataNo
230Composite check digit (for lines 1 & 2)Yes
31–30Name (Surname << Given names)No

TD2: The Intermediate Format

TD2 MRZ Example

TD2 provides a slightly larger area than TD1 and is often used for documents that don’t quite fit the passport size but require more data than a standard ID card.

Documents using TD2: German ID cards (older versions), various international Visas.

TD2 Structure (2 Lines x 36 Characters)

LinePositionsFieldCheck Digit
11–2Document codeNo
13–5Issuing StateNo
16–36Name (Surname << Given names)No
21–9Document numberYes (Pos 10)
211–13NationalityNo
214–19Date of birth (YYMMDD)Yes (Pos 20)
221SexNo
222–27Date of expiry (YYMMDD)Yes (Pos 28)
229–35Optional dataNo
236Composite check digitYes

TD3: The Passport Standard

TD3 MRZ Example

This is the format most people recognize. It is the global standard for passports (Machine Readable Passports - MRP).

Documents using TD3: International Passports.

TD3 Structure (2 Lines x 44 Characters)

LinePositionsFieldCheck Digit
11–2Document code (usually ‘P’ for Passport)No
13–5Issuing StateNo
16–44Name (Surname << Given names)No
21–9Passport numberYes (Pos 10)
211–13NationalityNo
214–19Date of birth (YYMMDD)Yes (Pos 20)
221SexNo
222–27Date of expiry (YYMMDD)Yes (Pos 28)
229–42Personal number / Optional dataYes (Pos 43)
244Composite check digitYes

Check Digits: Ensuring Data Integrity

One of the most powerful features of the MRZ is the Check Digit. Using a weighted modulus 10 algorithm, the MRZ allows systems to verify that the OCR engine hasn’t misread a “0” as an “O” or a “1” as an “I”. If the math doesn’t add up, the document is flagged for manual review.

Tools for Developers

If you are looking to parse raw MRZ strings in your application, there are several excellent open-source libraries available:

  • Python: The `mrz` library is the most popular choice for parsing and generating MRZ strings according to ICAO standards.
  • JavaScript/Node.js: `mrz-generator` or `mrz-parser` are great for client-side or server-side logic in web apps.
  • C#/.NET: `MRZ-Parser` libraries are available on NuGet to handle document validation.

Moving Beyond Parsing: OCR APIs

Parsing a string is easy, but extracting that string from a grainy photo of a passport is the hard part. To do this reliably at scale, you need a specialized OCR API.

Google Cloud Vision

A powerful general-purpose OCR. Highly scalable but can require significant configuration to handle complex ID backgrounds.

AWS Textract

Great for structured forms, though it may sometimes struggle with the specific formatting of international IDs.

Tiny IDP

Purpose-built for identity documents. Optimized specifically for passports and IDs, ensuring high-accuracy MRZ extraction even in suboptimal lighting.

Automate Your MRZ Extraction Tiny IDP supports international ID documents and passports OCR. Check out our International ID Document OCR

Try it out here

Conclusion

The MRZ remains the backbone of identity document processing. By understanding the differences between TD1, TD2, and TD3, you can build more robust systems for data entry and verification.

Ready to automate your ID data extraction? Try Tiny IDP today and see how our specialized OCR can streamline your document processing.

Tags
MRZIdentityOCRICAO