Back to blog
March 9, 20267 min read

What is the Machine Readable Zone (MRZ)? Complete Developer Guide

mrzpassportocrtutorialreference

If you've ever looked at the bottom of a passport's data page, you've seen two lines of seemingly random characters — letters, numbers, and chevrons (<). That's the Machine Readable Zone, or MRZ.

The MRZ was designed by ICAO (International Civil Aviation Organization) in the Doc 9303 standard to let machines quickly and accurately read passport data at border crossings. Many countries began issuing machine-readable travel documents in the 1980s, and as of April 1, 2010, ICAO requires all member states to issue only machine-readable passports. The MRZ encodes the holder's name, nationality, date of birth, passport number, and more — all in a fixed-width format that's easy for OCR engines to parse.

For developers building travel, document processing, or identity workflows, understanding MRZ is essential. This guide covers everything you need to know. For a broader overview, see the Wikipedia article on machine-readable passports and the Wikiwand version.

MRZ Document Types: TD1, TD2, and TD3

MRZ Highlight Example

A close-up view of a Machine Readable Zone on a passport data page.

ICAO defines three MRZ formats corresponding to ISO/IEC 7810 document sizes:

FormatLinesCharacters/LineUsed For
TD3244Passport booklets (ID-3 size: 125 x 88 mm)
TD2236Official travel documents (ID-2 size: 105 x 74 mm)
TD1330ID cards, passport cards (ID-1 size: 85.6 x 54 mm, credit card-sized)

There are also two machine-readable visa formats: MRV-A (2 x 44 chars) and MRV-B (2 x 36 chars).

Passports use TD3 — two lines of 44 characters each (88 characters total). This is the format we'll focus on, since it's the most common in API integrations.

TD3 Format: Field-by-Field Breakdown

Passport Example with MRZ

Here's an example passport MRZ (from the ICAO specification):

P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<
L898902C36UTO7408122F1204159ZE184226B<<<<<10

Line 1 — Identity

PositionLengthFieldExampleNotes
11Document typePP indicates a passport
21Type subcode<At the discretion of the issuing country (usually < filler)
3–53Issuing countryUTOISO 3166-1 alpha-3 code with modifications (UTO = ICAO test country)
6–4439NameERIKSSON<<ANNA<MARIA<<<...Surname << given names. < separates multiple given names. Padded with <.

Line 2 — Document Data + Check Digits

PositionLengthFieldExampleNotes
1–99Document numberL898902C3Alphanumeric
101Check digit6Over positions 1–9
11–133NationalityUTOISO 3166-1 alpha-3 with modifications
14–196Date of birth740812YYMMDD format
201Check digit2Over positions 14–19
211SexFM, F, or < (unspecified)
22–276Expiry date120415YYMMDD format
281Check digit9Over positions 22–27
29–4214Optional dataZE184226B<<<<<Personal number (country-dependent)
431Check digit1Over positions 29–42 (may be < if all positions are <)
441Composite check digit0Over line 2 positions 1–10, 14–20, 22–43

How MRZ Check Digits Work

Check digits are single-digit values calculated from the data they protect. They catch OCR errors and manual transcription mistakes.

The Algorithm

  1. Assign each character a numeric value:
    • 09 → 0–9
    • AZ → 10–35
    • < (filler) → 0
  2. Multiply each value by a weight, cycling through 7, 3, 1, 7, 3, 1, ...
  3. Sum all products
  4. The check digit = sum mod 10

Example: Document Number L898902C3

CharL898902C3
Value21898902123
Weight731731731
Product1472495627014363

Sum = 316. Check digit = 316 mod 10 = 6. Matches the MRZ.

Common MRZ Character Encoding Rules

The MRZ uses a restricted character set — only three types of characters are allowed:

  • A–Z (uppercase Latin letters only)
  • 0–9 (Arabic numerals)
  • < (filler character — replaces spaces, punctuation, and unused positions)

Name handling

  • Surnames and given names are separated by <<
  • Multiple given names are separated by single <
  • Spaces and hyphens in names are replaced by <
  • Apostrophes are omitted entirely (e.g., O'BrienOBRIEN)
  • Diacritics are transliterated per ICAO rules (e.g., MüllerMUELLER, ßSS, æAE)
  • If names are too long for the 39-character field, they are abbreviated to their most significant parts

Date Handling: The Y2K Issue

MRZ dates use YYMMDD format with no century indicator. The standard convention:

  • 00–99 for birth dates: interpret based on reasonable age (e.g., 990101 = 1999-01-01)
  • Expiry dates: typically within 10 years of issue, so context determines century

Most MRZ parsing libraries handle this automatically.

Extracting MRZ Data with an API

Passport OCR API Extraction Process

While you can parse MRZ text manually, the harder problem is detecting and reading the MRZ from a passport image. This requires:

OCR Scanning Process

An illustration of how OCR technology extracts data from a passport.

  1. Image preprocessing — rotation, cropping, contrast adjustment
  2. MRZ region detection — finding the two text lines at the bottom of the page
  3. OCR — converting the image region to text
  4. Parsing + validation — extracting fields and verifying check digits

With the Passport OCR API, you can do all of this in a single HTTP call:

curl -X POST https://passport-ocr.com/v1/ocr \
  -F "[email protected]"

Response:

{
  "success": true,
  "data": {
    "documentType": "PASSPORT",
    "documentNumber": "L898902C3",
    "issuingCountry": "UTO",
    "lastName": "ERIKSSON",
    "firstName": "ANNA MARIA",
    "nationality": "UTO",
    "dateOfBirth": "1974-08-12",
    "sex": "female",
    "expirationDate": "2012-04-15",
    "personalNumber": "ZE184226B"
  }
}

No setup, no API key required for your first 10 requests per day.

Why MRZ Still Matters

Despite being a decades-old standard (countries began adopting it in the 1980s), MRZ remains the most reliable way to extract passport data:

  • Standardized globally — every ICAO-compliant passport uses the same format, mandated since 2010
  • High OCR accuracy — the fixed-width monospaced font (OCR-B) was designed specifically for machine reading
  • Built-in error detection — check digits catch most OCR and transcription errors
  • Fast processing — parsing is deterministic, no AI/ML needed for the text parsing step

For developers building travel tech, hotel check-in, document workflows, or any system that needs passport data — MRZ extraction via OCR is the most practical approach.

Next Steps

Further Reading


Disclaimer: Some images in this post, including the passport and scanning illustrations, are AI-generated for illustrative purposes and do not represent real documents.

Ready to extract passport data?

Try Passport OCR free — 10 requests per day, no signup required.