Generate a test MRZ
Build a machine readable zone with correct check digits for testing OCR, document readers and identity verification flows. Names are converted using ICAO transliteration rules.
How names are converted
ICAO Doc 9303 Part 3 allows only A–Z in names. Diacritics are removed (Ā becomes A, Š becomes S, Ņ becomes N), Ä, Ö and Ü become AE, OE and UE, ß becomes SS, spaces and hyphens become <, and apostrophes are dropped. A name that does not fit the line is cut at the last position.
Which format to pick
Passports use TD3. Credit-card-sized ID cards and residence permits use TD1, which is also the only format that fits a document number longer than nine characters. TD2 is mostly found on older ID cards.
Annotated examples
The three ICAO specimen documents of the fictional state of Utopia, field by field. Line and position numbers start at 1.
TD3: passport, 2 lines of 44
P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<
L898902C36UTO7408122F1204159ZE184226B<<<<<10
| Line | Positions | Field | Value |
|---|---|---|---|
| 1 | 1–2 | Document code | P< |
| 1 | 3–5 | Issuing state | UTO |
| 1 | 6–44 | Name | ERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<< |
| 2 | 1–9 | Document number | L898902C3 |
| 2 | 10 | Number check digit | 6 |
| 2 | 11–13 | Nationality | UTO |
| 2 | 14–19 | Date of birth | 740812 |
| 2 | 20 | Birth date check digit | 2 |
| 2 | 21 | Sex | F |
| 2 | 22–27 | Date of expiry | 120415 |
| 2 | 28 | Expiry check digit | 9 |
| 2 | 29–42 | Optional data | ZE184226B<<<<< |
| 2 | 43 | Optional data check digit | 1 |
| 2 | 44 | Composite check digit | 0 |
TD2: 2 lines of 36
I<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<
D231458907UTO7408122F1204159<<<<<<<6
| Line | Positions | Field | Value |
|---|---|---|---|
| 1 | 1–2 | Document code | I< |
| 1 | 3–5 | Issuing state | UTO |
| 1 | 6–36 | Name | ERIKSSON<<ANNA<MARIA<<<<<<<<<<< |
| 2 | 1–9 | Document number | D23145890 |
| 2 | 10 | Number check digit | 7 |
| 2 | 11–13 | Nationality | UTO |
| 2 | 14–19 | Date of birth | 740812 |
| 2 | 20 | Birth date check digit | 2 |
| 2 | 21 | Sex | F |
| 2 | 22–27 | Date of expiry | 120415 |
| 2 | 28 | Expiry check digit | 9 |
| 2 | 29–35 | Optional data | <<<<<<< |
| 2 | 36 | Composite check digit | 6 |
TD1: ID card, 3 lines of 30
I<UTOD231458907<<<<<<<<<<<<<<<
7408122F1204159UTO<<<<<<<<<<<6
ERIKSSON<<ANNA<MARIA<<<<<<<<<<
| Line | Positions | Field | Value |
|---|---|---|---|
| 1 | 1–2 | Document code | I< |
| 1 | 3–5 | Issuing state | UTO |
| 1 | 6–14 | Document number | D23145890 |
| 1 | 15 | Number check digit | 7 |
| 1 | 16–30 | Optional data | <<<<<<<<<<<<<<< |
| 2 | 1–6 | Date of birth | 740812 |
| 2 | 7 | Birth date check digit | 2 |
| 2 | 8 | Sex | F |
| 2 | 9–14 | Date of expiry | 120415 |
| 2 | 15 | Expiry check digit | 9 |
| 2 | 16–18 | Nationality | UTO |
| 2 | 19–29 | Optional data (line 2) | <<<<<<<<<<< |
| 2 | 30 | Composite check digit | 6 |
| 3 | 1–30 | Name | ERIKSSON<<ANNA<MARIA<<<<<<<<<< |
What test MRZs are used for
Generated MRZs let you test without real identity documents. OCR and MRZ-parsing teams use them to cover every format, long names, missing optional data and edge cases such as document numbers longer than nine characters. KYC and onboarding teams use them in sandbox environments, where real passport data must not appear. Document reader and kiosk vendors use them in QA to check that a reader parses each field correctly and rejects a wrong check digit. Personalisation teams use them to prepare test specimens and compare the printed MRZ with the expected value.
Questions
- Are generated MRZs valid documents?
- No. They follow the format and check digit rules of ICAO Doc 9303, but they belong to no real document and must only be used for testing.
- Which country code should I use for test data?
- UTO, the code of the fictional state of Utopia used in all ICAO specimens. It cannot be confused with a real document. Use a real country code only when the system under test needs one.
- Why was the name shortened?
- The name field has a fixed length: 39 characters on a TD3 passport, 31 on TD2 and 30 on TD1. The generator cuts a longer name at the last position. ICAO Doc 9303 Part 3 describes more detailed truncation rules that issuing states may apply.
- Can a document number be longer than nine characters?
- Only on TD1 cards. The first nine characters go into the number field, position 15 holds <, and the rest of the number continues in the optional data, followed by its own check digit. TD2, TD3 and visas allow nine characters at most.