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

MRZ Explained: Machine Readable Zone Technical Guide

A technical guide to the Machine Readable Zone: ICAO 9303 TD1, TD2, and TD3 layouts, check digits, parsing pitfalls, and its relationship to NFC chips.

By DiditUpdated
mrz-machine-readable-zone-technical-guide.png

MRZ means Machine Readable Zone: the standardized block of fixed-width characters printed on passports, identity cards, and other machine-readable travel documents.

It encodes selected identity and document fields for optical character recognition. Check digits help detect reading or transcription errors. They do not prove that the document is genuine, that a trusted authority issued the data, or that the presenter is the rightful holder.

Key takeaways

  • MRZ is a family of layouts, not one universal string. TD1 uses three lines of 30 characters, TD2 uses two lines of 36, and TD3 uses two lines of 44.
  • Positions carry meaning. A parser must preserve line boundaries, field widths, filler characters, and the schema selected for that document.
  • Check digits detect errors; they are not signatures. ICAO’s modulus-10 calculation uses character values and repeating weights of 7, 3, and 1.
  • Names and dates need policy, not guesswork. Transliteration, truncation, fillers, and two-digit years can make a syntactically valid parse semantically uncertain.
  • MRZ and NFC serve different trust functions. MRZ is optically readable data; an authenticated ePassport chip can provide digitally signed data and optional anti-cloning evidence.

What is an MRZ?

The Machine Readable Zone is the mandatory machine-readable area of an ICAO-compliant machine-readable travel document. It appears separately from the Visual Inspection Zone (VIZ), where a person sees labels, full dates, a portrait, and other document details.

ICAO Doc 9303 defines the travel-document system across multiple parts. Part 3 contains specifications common to machine-readable travel documents. Parts 4, 5, and 6 define the TD3, TD1, and TD2 layouts respectively. The layouts use OCR-B characters and a deliberately restricted repertoire:

  • uppercase letters A through Z;
  • digits 0 through 9;
  • the filler character <.

The filler is not decorative. It pads unused fixed-width fields, replaces spaces or unsupported punctuation where specified, and separates name components. Removing every < before parsing destroys information about field boundaries and names.

The MRZ repeats selected document data. It is optimized for interoperable capture, not for preserving every visual field or national-script name.

TD1, TD2, and TD3 formats compared

The first parsing decision is the document layout. Line count and exact width provide the strongest initial discriminator.

FormatTypical form factorMRZ shapeTotal charactersName location
TD1Credit-card-size official travel document or identity card3 × 3090Line 3
TD2Larger card or booklet data page2 × 3672Line 1
TD3Machine-readable passport and other TD3 documents2 × 4488Line 1

Do not infer the format only from a document code such as P or I. Capture can omit a line, join two lines, insert spaces, or return a crop from the wrong region. Validate both geometry and permitted characters before assigning field positions.

TD1: three lines of 30 characters

Doc 9303 Part 5 defines TD1-size machine-readable official travel documents. Because the card is compact, the MRZ spans three lines.

TD1 line 1: document and optional data

PositionsLengthField
1–22Document code
3–53Issuing State or organization
6–149Document number
151Document-number check digit
16–3015Optional data

The first character of the document code is A, C, or I under the Part 5 layout. Unused optional positions are filled with <.

For a document number longer than nine characters, upper-line position 15 is <. Continuation characters use positions 16 through at most 28; the number's check digit immediately follows in positions 17–29, and a filler follows that digit. Parse this exception before treating positions 16–30 as optional data.

TD1 line 2: holder attributes and composite check

PositionsLengthField
1–66Date of birth in YYMMDD form
71Birth-date check digit
81Sex: F, M, or `<`
9–146Date of expiry in YYMMDD form
151Expiry-date check digit
16–183Nationality
19–2911Optional data
301Composite check digit

The composite digit covers upper-line positions 6–30, then middle-line positions 1–7, 9–15, and 19–29. It excludes the holder's name on line 3. Concatenate these exact ranges in order.

TD1 line 3: name

All 30 positions hold the name. Two fillers, <<, separate the primary identifier—usually the surname or surnames—from secondary identifiers. A single < separates components within either group.

For example:

ERIKSSON<<ANNA<MARIA<<<<<<<<<<

This represents the primary identifier ERIKSSON and secondary identifiers ANNA MARIA, followed by padding. Use the issuer’s identifier groups instead of assuming that every culture uses one surname followed by given names.

TD2: two lines of 36 characters

Doc 9303 Part 6 defines the TD2 layout.

TD2 line 1

PositionsLengthField
1–22Document code
3–53Issuing State or organization
6–3631Name

As in TD1, the first document-code character is A, C, or I. The name follows the same primary-identifier, <<, secondary-identifier structure, but its available length differs.

TD2 line 2

PositionsLengthField
1–99Document number
101Document-number check digit
11–133Nationality
14–196Date of birth
201Birth-date check digit
211Sex
22–276Date of expiry
281Expiry-date check digit
29–357Optional data
361Composite check digit

The composite digit covers positions 1–10, 14–20, and 22–35. Nationality positions 11–13 and sex position 21 are excluded. That exclusion is a common source of “almost correct” implementations.

For a document number longer than nine characters, positions 1–9 hold its nine principal characters, position 10 is <, and the remaining characters start in positions 29–35. The document-number check digit follows the final continuation character, then a filler. Apply this exception before interpreting positions 29–35 solely as optional data.

TD3: two lines of 44 characters

Doc 9303 Part 4 defines machine-readable passports and other TD3-size documents.

TD3 line 1

PositionsLengthField
1–22Document code
3–53Issuing State or organization
6–4439Name

For a machine-readable passport, the first document-code character is P. The second character identifies a passport type under the applicable Part 4 rules. Name components use the same filler-based structure as TD1 and TD2.

TD3 line 2

PositionsLengthField
1–99Passport number
101Passport-number check digit
11–133Nationality
14–196Date of birth
201Birth-date check digit
211Sex
22–276Date of expiry
281Expiry-date check digit
29–4214Personal number or optional data
431Optional-field check digit
441Composite check digit

When the optional personal-number field is unused and filled with <, Part 4 allows its check position to be 0 or < at the issuer’s option. A validator should accept the permitted variant without weakening checks on fields that are populated.

The final composite digit covers positions 1–10, 14–20, and 22–43. It therefore includes the individual check digits in those ranges but excludes nationality and sex.

How MRZ check digits work

ICAO check digits use a deterministic modulus-10 calculation.

1. Convert each character to a value

CharacterValue
090–9
AZ10–35
`<`0

2. Apply repeating weights

Starting with the first character in the protected field, multiply values by:

7, 3, 1, 7, 3, 1, ...

3. Sum and take the remainder

Add the products and calculate the sum modulo 10. The remainder, from 0 to 9, is the check digit.

For the sample passport number L898902C3:

Characters: L   8   9   8   9   0   2   C   3
Values:    21   8   9   8   9   0   2  12   3
Weights:    7   3   1   7   3   1   7   3   1
Products: 147  24   9  56  27   0  14  36   3
Sum: 316
316 mod 10 = 6

The expected check digit is 6.

Validate individual digits and the composite digit. An individual failure identifies a likely field-level problem; a composite-only failure can indicate an error in optional data, range construction, or another covered character.

Check digits catch many substitutions and transpositions, but an attacker can recompute them. They provide error detection, not authenticity against forgery.

Parsing pitfalls that break production systems

Losing fixed-width structure

Trimming each line, collapsing <, or deleting line breaks before format detection shifts fields. Normalize outer whitespace only after isolating the MRZ, then require exactly 30, 36, or 44 characters per line.

Treating OCR output as ground truth

OCR commonly confuses O with 0, I with 1, and B with 8. Do not apply a global replacement: letters are valid in document numbers, and digits are valid in dates. Use the field’s permitted character set, check digits, the VIZ, and another capture to guide recovery. Record both the raw OCR result and any correction.

Removing fillers too early

< can mean padding, a separator, an unspecified value, or a replacement required by the schema. Parse positions first. Interpret fillers only within the selected field.

Assuming the MRZ preserves the printed name

The MRZ omits punctuation, transliterates national characters, and can truncate names to fit. << separates identifier groups; < within a group separates components. Store the raw MRZ name and the document’s visual or authoritative name separately rather than silently overwriting one with the other.

An alphabetic character in the last available name position signals possible truncation. A name can exactly fill the field and trigger the same signal, so treat it as uncertainty.

Inferring the wrong century

MRZ birth and expiry dates use two-digit years. The check digit validates the six printed digits but does not choose a century. Resolve the full date with document type, expiry rules, capture date, holder context, and explicit policy. Keep the raw YYMMDD value so a later rule change remains auditable.

Treating three-letter codes as a generic country library lookup

Issuing authority and nationality use the code set specified by Doc 9303, which includes organizations and special values as well as States. A strict ISO-only mapping can reject valid documents or mislabel the issuer. Version and test the ICAO code table used by the parser.

Ignoring issuer options and long document numbers

Optional data is issuer-defined, and long document-number rules can relocate continuation characters and a check digit. Do not assign a universal meaning to every optional field or concatenate it into the document number without format-specific evidence.

“Repairing” a failed check digit silently

A failed digit may come from glare, crop, a damaged line, an unsupported issuer convention, or manipulation. Preserve the raw capture, identify the failed field, and request a controlled recapture or review. Silent correction erases the evidence needed to understand the failure.

MRZ versus NFC chip data

MRZ and NFC are complementary, not competing versions of the same check.

PropertyPrinted MRZContactless ePassport or eID chip
CaptureCamera, scanner, or manual transcriptionNFC-capable reader
DataSelected fixed-width identity and document fieldsStructured data groups, potentially including a higher-quality portrait
Error controlModulus-10 check digitsData-group hashes and digital signatures when authenticated
AuthenticityNot established by the MRZ alonePassive Authentication can establish issuing-authority signature and data integrity
Anti-cloningNoneActive Authentication or Chip Authentication may provide evidence when supported
AvailabilityBroad across machine-readable travel documentsOnly documents with a supported contactless chip and readable device path

The MRZ can also participate in chip access. ICAO’s ePassport access-control guidance explains that Basic Access Control derives an access key from data read from the passport data page, normally through the MRZ. PACE is a stronger access-control protocol encountered in newer documents. Access control protects chip communication; it is not the same as authenticating the issuer’s signature.

After access, Passive Authentication checks the digital signature so the inspection system can determine whether the chip data was saved by the issuing authority and altered later. Optional active or chip-authentication mechanisms can add anti-cloning evidence.

A robust document flow can therefore:

  1. capture the MRZ and validate its structure and check digits;
  2. use the required access data to establish a protected NFC session;
  3. read the chip data groups;
  4. perform Passive Authentication against trusted issuer certificates;
  5. perform an anti-cloning mechanism when the document supports it;
  6. compare chip, MRZ, and visible document data;
  7. separately verify that the applicant is linked to the document.

Reading a chip without validating its signature is not equivalent to authenticating it. Likewise, a valid chip does not by itself prove that the current applicant is its rightful holder.

Implementation and security checklist

Before shipping an MRZ parser:

  • detect TD1, TD2, or TD3 from exact line geometry before slicing fields;
  • preserve the raw image, raw OCR lines, normalized lines, and parser version;
  • accept only the permitted MRZ character repertoire after controlled normalization;
  • parse by one-based ICAO positions translated carefully into the programming language’s indexing;
  • validate every applicable field digit and the format-specific composite digit;
  • support issuer-permitted empty-field and long-document-number cases;
  • retain raw and interpreted dates, codes, names, and optional data separately;
  • surface truncation and century inference as explicit uncertainty;
  • compare MRZ results with VIZ or chip data without silently overwriting mismatches;
  • avoid placing MRZ strings in analytics, URLs, crash reports, or routine logs;
  • encrypt sensitive retained data and apply access, retention, and deletion policy;
  • test genuine samples across issuers, formats, long names, damaged captures, and OCR confusions;
  • fuzz line lengths, fillers, invalid characters, and check-digit failures;
  • keep document acceptance policy separate from parsing success.

A parser answers, “What characters are encoded, and are the check digits consistent?” Document authentication and holder verification require additional evidence.

Where Didit fits

Didit lists ID Verification and NFC Reading as separate document-and-identity modules. Their published prices are $0.15 each. The Workflow Orchestrator is listed as free.

Those product links do not change the trust distinction in this guide: MRZ parsing, chip authentication, document policy, and holder linkage remain separate conclusions. Current module rates are available on the pricing page.

Frequently asked questions

What does MRZ stand for?

MRZ stands for Machine Readable Zone, the standardized fixed-width character area printed on machine-readable travel documents.

Where is the MRZ on a passport?

On a TD3 passport data page, it is the two-line block of 44 characters per line, normally at the bottom of the data page.

What is the difference between TD1, TD2, and TD3?

They are ICAO document sizes and MRZ layouts. TD1 has three lines of 30 characters, TD2 has two of 36, and TD3 has two of 44.

Can an MRZ check digit prove a passport is genuine?

No. It detects many accidental reading errors. It is not a digital signature and can be recomputed after data is changed.

Why does an MRZ use the < character?

It fills unused positions, replaces spaces or unsupported punctuation where required, separates name components, and can represent an unspecified field in defined contexts.

Is the MRZ the same data as the NFC chip?

No. Some identity fields overlap, but the chip can store structured data groups and cryptographic security objects. Proper chip authentication can provide evidence that the signed data came from the issuing authority and was not altered.

Should an application trust OCR-corrected MRZ data?

Only with explicit evidence. Corrections should be field-aware, supported by check digits or another source, and retained alongside the raw OCR result. Unresolved inconsistencies should trigger recapture or review.

Primary references

Conclusion

The MRZ succeeds because it is constrained: fixed line lengths, fixed positions, a limited character set, and predictable check digits. Those same constraints demand disciplined parsing. Keep raw structure intact, select the correct TD layout, calculate exact protected ranges, and preserve uncertainty around names, dates, and issuer-specific options.

Then stop at the boundary of what the evidence proves. A valid MRZ is useful interoperable data. Authenticated NFC chip data can add cryptographic document evidence. Holder verification and the final business decision remain separate steps.

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