...

Reading the MRZ of passports and ID cards

MRZ recognition from a photo or scan: NeuroVision finds the machine-readable zone on a passport, ID card or residence permit, reads the lines, recalculates the check digits and compares them with the data on the document page. The MRZ lines and the parsed fields arrive in JSON through the REST API or the web widget — together with the rest of the document data.

MRZ recognition from a photo: the machine-readable zone on a specimen passport is outlined with a frame
  • TD1, TD2 and TD3 under ICAO Doc 9303
  • MRZ of a Russian internal passport with Cyrillic encoding
  • 16,000+ document types from 195+ countries and territories
Data is stored in Russia Russian Software Registry No. 19972 Compliance with 152-FZ

What the MRZ is and what your system gets from it

  • Only Latin letters, digits and «<»

    The MRZ has 37 permitted characters: the letters A–Z, the digits 0–9 and the filler character «<», which replaces spaces and empty positions. The font is the monospaced OCR-B, so every position stays in its place.

  • The data duplicates the document page

    Document type, issuing country, surname and given name, number, nationality, date of birth, sex and expiry date — the same details that are printed for a person in the visual zone (VIZ).

  • Check digits protect the fields

    The document number, the dates and the optional data are followed by check digits. A misread character or an edited field changes the result of the calculation.

  • Your system receives ready-made fields

    The service does not simply “see text”: it detects the format, splits the lines into fields, brings the dates to a single format and returns the MRZ check status in one API response.

The MRZ is not the chip. The machine-readable zone (MRZ, ICAO Doc 9303) is printed on paper and is read from an ordinary photograph; the chip can only be read over NFC — see the differences in the “OCR of the MRZ vs. reading the chip” block. Where the MRZ is on a passport and how it is used to check for forgeries by hand — in the article on the machine-readable zone.

MRZ formats under ICAO 9303: TD1, TD2, TD3 and visas

Documents with an MRZ come in three sizes, each with its own line layout. The service detects the format by itself — from the number of lines, their length and the document code in the first positions — so reading the MRZ of a document does not require the user to choose the type in advance.

An MRV-A visa line is easy to confuse with a passport line: it has the same length, but the first letter is V and the set of fields is different. The model tells them apart by the document code.

  • TD1

    Card documents: ID-1, three lines of 30 characters.

    Layout

    • Lines × characters: 3 × 30
    • Document size: ID-1, like a bank card (85.6 × 54 mm)
    • Where it is found: ID cards, card-format residence permits

    Code and fields

    • First letter of the document code: I, A or C
    • Where the surname and given name are: third line
    • Document number: 9 characters, line 1
    • Check digits: number, date of birth, expiry date, composite

    Visas and standard

    • Part of Doc 9303: Part 5
  • TD3

    Passports: ID-3, two lines of 44 characters — the main format of this page.

    Layout

    • Lines × characters: 2 × 44
    • Document size: ID-3, a passport page (125 × 88 mm)
    • Where it is found: passports, including the Russian international passport and the Russian internal passport

    Code and fields

    • First letter of the document code: P
    • Where the surname and given name are: first line
    • Document number: 9 characters, line 2
    • Check digits: number, date of birth, expiry date, optional data, composite

    Visas and standard

    • Visas of this size: MRV-A: 2 × 44, a full-page visa
    • Part of Doc 9303: Part 4
  • TD2

    Mid-size documents: ID-2, two lines of 36 characters.

    Layout

    • Lines × characters: 2 × 36
    • Document size: ID-2 (105 × 74 mm)
    • Where it is found: some ID cards and travel documents; new issues are moving to TD1

    Code and fields

    • First letter of the document code: I, A or C
    • Where the surname and given name are: first line
    • Document number: 9 characters, line 2
    • Check digits: number, date of birth, expiry date, composite

    Visas and standard

    • Visas of this size: MRV-B: 2 × 36, a smaller visa
    • Part of Doc 9303: Part 6 (visas — Part 7)

What a passport MRZ consists of: line by line

Example MRZ of an international passport (fictitious data)

MRZ
P<RUSTSVETKOVA<<IULIIA<<<<<<<<<<<<<<<<<<<<<<
0000000000RUS9001011F3001019<<<<<<<<<<<<<<06

  • Document type: P — passport, the second character is a subtype or «<» pos. 1–2
  • Issuing state: a three-letter code (RUS for Russia) pos. 3–5
  • Surname, «<<», given name; spaces and hyphens — «<», a long name is truncated pos. 6–44VIZ

  • Document number pos. 1–9VIZ
  • Document number check digit pos. 10Check
  • Citizenship pos. 11–13VIZ
  • Date of birth, YYMMDD pos. 14–19VIZ
  • Date of birth check digit pos. 20Check
  • Sex: M, F or «<» pos. 21VIZ

  • Expiry date, YYMMDD pos. 22–27VIZ
  • Expiry date check digit pos. 28Check
  • Personal number or optional data (at the state's discretion) pos. 29–42
  • Optional data check digit pos. 43Check
  • Composite check digit — over the number, the dates and the optional data together pos. 44Check

  • TD1: the number and optional data are in the first line, the dates and sex in the second, the name in the third 3 × 30
  • TD2: the layout is like a passport's, but the line is shorter and there are 7 positions of optional data 2 × 36
  • The TD1 composite check digit is calculated over the fields of the first two lines Check
  • A passport is the TD3 format: two lines of 44 characters. Above is an example of the lines of a fictitious international passport and the meaning of each position. This is how the service splits the zone into fields before checking.
  • Check — the field is protected by a check digit
  • VIZ — the value is compared with the visual zone
  • Years in the MRZ are written with two digits. The service determines the century from the meaning of the field: a date of birth cannot be in the future, an expiry date cannot be in the distant past. In the API response the dates arrive both as on the document and in ISO format (valueUTC). How check digits are recalculated by hand — in our article

MRZ of a Russian passport and an international passport: what is the difference

A Russian citizen has two documents with an MRZ, and they are built differently. The international passport is an ordinary ICAO TD3: type P, the name in Latin letters under the transliteration rules, the expiry date in line 2. In the Russian internal passport (since 1 July 2011) the document code is PN, the full name is written by encoding, there is no expiry date, but there are the series, the issue date and the issuing-authority code.

The service knows both schemes and splits each into fields. Passports issued before July 2011 have no MRZ — they are read from the visual zone (the page about passport recognition). More on the form and its protection — in the article “Security features of a Russian passport”.

One surname in the MRZ of an international passport and of a Russian passport: transliteration and encoding
Result of reading the MRZ of an international passport: the surname in Latin letters and the expiry date Result of reading the MRZ of a Russian internal passport: the series, the issue date and the issuing-authority code

Example MRZ of a Russian internal passport (fictitious data)

MRZ
PNRUSCVETKOVA<<7LI8<PETROVNA<<<<<<<<<<<<<<<<
0000000000RUS9001011F<<<<<<<0200101000000<62

Line 2, positions 1–9 — the first three digits of the series and the number; 22–28 — empty; 29–42 — the last digit of the series, the issue date (YYMMDD) and the issuing-authority code without the hyphen. The check digits use the same 7‑3‑1 algorithm as in the international passport.

One surname — three spellings: MRZ encoding and transliteration

  • MRZ of a Russian internal passport: encoding

    Ё → 2 · Ж → J · Й → Q · Х → H · Ц → C · Ч → 3 · Ш → 4 · Щ → W · Ъ → X · Ы → Y · Ь → 9 · Э → 6 · Ю → 7 · Я → 8

  • Russian international passport: transliteration under ICAO Doc 9303

    Ё → E · Ж → ZH · Й → I · Х → KH · Ц → TS · Ч → CH · Ш → SH · Щ → SHCH · Ъ → IE · Ы → Y · Ь → — (not transmitted) · Э → E · Ю → IU · Я → IA

  • GOST 7.79-2000, system B — not used in passports

    Ё → YO · Ж → ZH · Й → J · Х → X · Ц → CZ or C · Ч → CH · Ш → SH · Щ → SHH · Ъ → '' (two apostrophes) · Ы → Y' · Ь → ' (apostrophe) · Э → E' · Ю → YU · Я → YA

Example: Цветкова Юлия: CVETKOVA<<7LI8 (internal passport), TSVETKOVA IULIIA (international passport), CZVETKOVA YULIYA (GOST). The other letters coincide in all three systems (А — A, Б — B, В — V, etc.). The transliteration in an international passport can be changed on request (both “YULIYA” and “IULIIA” are found in the MRZ): the service does not treat such a discrepancy as an error if the MRZ line matches the Latin text of the visual zone of the same document. Comparing a client's different documents with each other is separate logic of your system.

MRZ check: check digits

What does the checksum in a passport mean? It is a digit calculated from the neighbouring MRZ characters. The service recalculates it for each protected field and compares it with the printed one. A mismatch means a reading error, a damaged document or altered data — in the API response this is isMRZValid and the error [document] bad mrz checksum.
Check digits catch errors and crude edits but do not prove authenticity: the algorithm is published, and whoever forged a document can recalculate them. That is why the service compares the MRZ with the visual zone (the block below) and looks for traces of image editing — document authenticity check.

  • Document number

    A digit after the nine characters of the number. It catches a typo and a swap of adjacent digits — the most frequent errors of both manual entry and OCR.

    • TD1 · TD2 · TD3
  • Date of birth

    Protects the six digits YYMMDD. A changed year of birth without recalculating the digit is visible at once.

    • TD1 · TD2 · TD3
  • Valid until

    Protects the expiry date. In the MRZ of a Russian internal passport the field is empty, and a «<».

    • TD1 · TD2 · TD3
  • Optional data

    In a passport — a personal number or data at the state's discretion. In a Russian passport this is the issue date and the issuing-authority code, and they are also under control.

    • TD3
  • Composite digit

    Calculated over the number, the dates and the optional data together. It matches only if all the fields are consistent at once.

    • TD1 · TD2 · TD3
  • The 7‑3‑1 algorithm

    Digits are taken as they are, the letters A–Z as 10–35, «<» as 0. The values are multiplied cyclically by 7, 3 and 1, the products are added up, and the remainder of division by 10 is the check digit. Example: the date 900101 → 9×7 + 0×3 + 0×1 + 1×7 + 0×3 + 1×1 = 71 → 1.

    • ICAO Doc 9303

How MRZ recognition works: from a photo to JSON

The MRZ is read together with the whole document in one request: the client takes a photo, and your system receives the zone lines, the parsed fields and the check statuses. All passport fields, including the registration page.

Step 1

Capture with prompts

The web widget shows a frame and prompts, and the quality check filters out blurred, dark and cropped shots. The bottom edge of the document with the MRZ must fit in the frame entirely.

Capturing a document in the web widget: a prompt to keep the MRZ in the frame
Step 2

Finding the zone and the format

The model finds the document, straightens the perspective and detects the MRZ: the number of lines, their length and the document code. That makes clear whether it is TD1, TD2 or TD3 and whose document it is.

Detecting the MRZ format: a TD3 passport and a TD1 ID card
Step 3

Reading the characters

Each position is read taking into account the OCR-B font and what can stand in it: a date field never contains letters, a country code never contains digits. So “0” is not confused with “O”, nor “1” with “I”.

Character-by-character MRZ reading taking into account the permitted characters in each position
Step 4

Check digits and comparison

The service recalculates the check digits and compares the MRZ with the fields of the visual zone: surname, number, dates, sex. For a Russian passport — taking the Cyrillic encoding into account.

Recalculating the check digits and comparing the MRZ with the visual zone
Step 5

Response in JSON

The MRZ lines, fields with a confidence level, dates in ISO format and the status isMRZValid arrive in the API response. The decision — accept, retake or send to an operator — is yours.

MRZ lines and fields in the JSON response of the API

Comparing the MRZ with the visual zone of the document

If a field in a document has been altered, it is most often altered where a person can see it — in the visual zone. The machine-readable zone then stays as it was or is recalculated with an error. The service compares both zones field by field and shows where they differ. The illustrations show a fictitious document “SPECIMEN”. A discrepancy is a reason to retake the document or send the application for manual review, not a conclusion of forgery: glare, a bent corner or an old form also cause reading errors.

A surname discrepancy between the visual zone and the MRZ of a document

Surname and given name

In the visual zone the surname is one, and in the MRZ it is different or truncated against the rules. The comparison takes transliteration and the truncation of long names into account, so that “IULIIA” and “Юлия” are not treated as a discrepancy.

OCR of the MRZ vs. reading the chip of an international passport: what to choose

In a biometric international passport the data is stored twice: printed in the MRZ and written to an electronic chip. These are two different ways to obtain the data, and each has its own job.

How OCR of the MRZ from a photo differs from reading the chip
CriterionReading the RFID chip over NFCOCR of the MRZ from a photo — NeuroVision
What the client needsa smartphone with NFC and a native appa phone or computer camera, a browser
Which documentsonly documents with a chip (eMRTD)all documents with an MRZ, including those without a chip: the Russian internal passport, old international passports, ID cards
How the data is obtainedthe app opens the chip with a key derived from the MRZ and reads the recorded datathe lines in the image are recognised
What it confirmsthe data was recorded when the document was issued and signed with the state's digital signaturethe data is consistent with itself and with the visual zone
Holder's photoa digital photograph from the chipis cut out from the page image
Where it worksonly in an app, the document is held against the phonea website, a mobile browser, WebView, an office
Available in NeuroVisionnoyes

NeuroVision does not read the chip. The service works with the image of the document: it reads the MRZ and the visual zone, compares them and looks for traces of image editing. If your procedure requires a cryptographic check of the chip data, a separate app with NFC performs it. For mass onboarding where documents are sent as a photograph and not every client has a biometric passport, OCR of the MRZ solves the task without installing an app.

Why the MRZ is not read and how to fix it

  • 01

    Glare on the lamination

    The passport page is covered with film, and a flash or a lamp leaves a spot right on the MRZ lines. It helps to shoot without a flash and at a slight angle to the light source — the widget prompts “remove the glare”.

  • 02

    Cropped bottom edge

    The MRZ is the lowest part of the page, and the frame or a finger cuts it off first. If the lines are not entirely visible, the service will return [document] cropped orbad mrz checksum and ask for a retake.

  • 03

    Blur and perspective

    The monospaced font is small: with motion blur “8” becomes “B”, “5” becomes “S”. The service straightens the perspective and takes into account which characters are allowed in each position, but a sharp shot is more reliable than any correction. How to reduce the number of retakes — in the article “Why users retake documents”. OCR and MRZ quality metrics — in the article “How to improve the accuracy of AI OCR and MRZ checks in KYC”.

  • 04

    Damage and old forms

    Worn, stained or torn pages are read worse. Russian internal passports issued before July 2011 have no MRZ at all — their data is taken from the visual zone.

What the API returns if the MRZ is not read

The error code and a prompt for the client — from the error reference

  • 15 bad mrz checksum: the checksums do not match or the lines are not fully visible
  • 34 cropped: the document is not fully visible
  • 38 the field was recognised with low confidence

API response: MRZ lines and fields in JSON

KYC with an MRZ check is connected with one method: the zone lines, the parsed fields and the MRZ status arrive together with the rest of the document data. No separate integration for the MRZ is needed.

REST API

The method POST https://api.neuro-vision.ru/v1/kyc/process accepts document images (a JWT or a permanent token) and returns the document type, the fields ocr.fields (title, value, conf) and the checks of the group fraud, among them isMRZValid. Synchronous and asynchronous mode. API documentation · Error codes

  • Fields in JSON
  • Confidence for every field
  • Registration and MRZ
  • Sandbox and documentation

Terms

Test access for 1 month, a personal manager, support through a ticket system, payment only for recognised documents.

Request

cURL
curl -X POST "https://api.neuro-vision.ru/v1/kyc/process" \
  -H "token: <jwt-token>" \
  -F "images=@passport.jpg" \
  -F "ocr=true" \
  -F "mode=sync"

Response: an international passport with an MRZ

JSON
{
  "status": "success",
  "results": [
    {
      "status": "success",
      "type": "passport",
      "docName": "RUS — ePassport (2021)",
      "errors": [],
      "checks": [
        {
          "caption": "fraud",
          "items": [
            { "caption": "isMRZValid", "status": "success" },
            { "caption": "isEdited", "status": "success" }
          ]
        }
      ],
      "ocr": {
        "status": "success",
        "fields": [
          { "title": "Surname", "value": "TSVETKOVA", "conf": "high" },
          { "title": "Given name(s)", "value": "IULIIA", "conf": "high" },
          { "title": "Document number", "value": "000000000", "conf": "high" },
          { "title": "Date of birth", "value": "01.01.1990", "valueUTC": "1990-01-01T00:00:00Z", "conf": "high" },
          { "title": "Date of expiry", "value": "01.01.2030", "valueUTC": "2030-01-01T00:00:00Z", "conf": "high" },
          { "title": "MRZ Strings", "value": "P<RUSTSVETKOVA<<IULIIA<<<<<<<<<<<<<<<<<<<<<<\n0000000000RUS9001011F3001019<<<<<<<<<<<<<<06", "conf": "high" }
        ]
      }
    }
  ]
}

If the MRZ was not read or the check digits do not match, in errors you will get [document] bad mrz checksum. What to do — retake, send to an operator or reject — is up to you.

Where MRZ reading is needed

The MRZ helps where there are many documents of foreigners and international passports, and the data is needed in Latin letters and without errors. Checking non-residents against sanctions lists and databases.

  • Hotels and hostels

    • A foreign guest's data from the passport in seconds at check-in
    • Latin letters and dates without manual entry
    • Shorter queues at the front desk
  • Tour operators and ticket sales

    • Surname and given name in Latin letters exactly as in the MRZ of the international passport — fewer booking errors
    • The passport expiry date is visible at once
  • Banks

    • Serving foreign citizens and non-residents
    • KYC with an MRZ check in remote onboarding Learn more
  • Fintech and payment services

    • Registering clients from different countries by ID cards and passports
    • An MRZ error is a signal for anti-fraud Learn more
  • Brokers and investment platforms

    • A non-resident application without typos in the number and dates
    • Data goes straight to the back office Learn more
  • Employers and recruitment agencies

    • Onboarding foreign employees by passport and ID card
    • Data for records without retyping

How much MRZ recognition costs

MRZ reading and checksum verification are included in document recognition — there is no separate charge for the MRZ. There is no subscription fee.

Calculate the cost
  • 01

    Document recognition and anti-fraud — from 16 ₽, MRZ checksum verification included

  • 02

    An additional document in the same check — an ID card, a residence permit or a visa — 10 ₽

  • 03

    First month — a free test on your own documents

MRZ glossary

Terms found in the ICAO standard, in the API documentation and in document-verification requirements.

MRZ
Machine-readable zone: two or three lines at the bottom of the document page, where the data is written in Latin letters, digits and the «<» character for automatic reading. The Russian-language name is «машиночитаемая зона».
Machine Readable Zone
VIZ
The visual zone is the part of the page where the data is printed for a person: the photo, full name, dates, number.
Visual Inspection Zone
ICAO Doc 9303
The International Civil Aviation Organization standard for machine-readable travel documents: MRZ formats, font, the check digit algorithm, transliteration, the electronic chip.
TD1, TD2, TD3
Document sizes and their MRZ: TD1 — a card, 3 × 30 characters; TD2 — 2 × 36; TD3 — a passport, 2 × 44.
MRV-A and MRV-B
Machine-readable visas: MRV-A — 2 lines of 44 characters, MRV-B — 2 of 36.
Check digit
A digit calculated by the 7‑3‑1 algorithm from the characters of a protected field. It catches reading errors and edits but does not prove authenticity.
The filler character «<»
Replaces spaces, hyphens and empty positions; a double «<<» separates the surname from the given name.
OCR-B
The monospaced font in which the MRZ is printed: every character has a fixed width.
Russian passport MRZ encoding
The way Cyrillic is written in the internal passport: letters without a Latin counterpart are replaced with digits and letters, for example Ч — 3, Ю — 7.
eMRTD
An electronic machine-readable travel document — a passport or ID card with a chip. The chip data is read over NFC; NeuroVision does not read the chip.

Connect MRZ reading for free

Send us your task — we will give you test access to the API and the web widget for a month and check MRZ reading on your documents.

Can't put your request into words? Book a call and our team will contact you at a convenient time

Book a call

The company is included in the register of IT companies and the register of personal data operators of the Russian Ministry of Digital Development.

Address: Moscow, Presnenskaya Embankment 12 — Moscow City business centre, Federation Tower. Nearest metro stations: Delovoy Tsentr and Mezhdunarodnaya.

Frequently asked questions about MRZ reading

Answers about passport types, the registration page, accuracy, data storage and integration

It is two lines of Latin letters and digits at the bottom of the page with the photograph, in which, under ICAO Doc 9303, the document type, country, surname and given name, number, dates and check digits are recorded. On ID cards the MRZ has three lines and is on the back. The zone is needed so that the document data can be read automatically and verified.

Passports (TD3 format), ID cards and card-format residence permits (TD1) and TD2 documents from 195+ countries and territories, including the Russian international passport and internal passport. The full list is in the documentation; forms without an MRZ are marked “not MRZ” there.

Yes, in the Russian internal passport the machine-readable record has been filled in since 1 July 2011: it is at the bottom of the third page. Passports issued earlier have no zone — these are legal documents, and the service takes their data from the visual zone.

In the internal passport Cyrillic is written with an encoding, not a transliteration: letters without a Latin counterpart are replaced with digits and letters, for example Ч — 3, Ш — 4, Ю — 7, Я — 8. The service knows this table and compares such a record with the full name on the page.

In an international passport the surname and given name are written in Latin letters under rules based on ICAO Doc 9303: Ю — IU, Я — IA, Ц — TS. GOST 7.79 is not used in passports. At the citizen's request the spelling may be different, for example as in a previous passport, so the MRZ is compared with the Latin text of the same document.

Not necessarily. Check digits confirm that the record is consistent, but the algorithm is published, and whoever altered the document can recalculate them. That is why the service also compares the MRZ with the visual zone and looks for traces of image editing.

No. The service works with the image of the document: it reads the MRZ and the visual zone from a photo. The chip of a biometric passport is read only over NFC in a separate app; on the other hand, OCR of the MRZ works in a browser and for documents without a chip.

Ask the client to retake the document without a flash so that the bottom lines fit in the frame entirely. The API will indicate the reason with an error code: bad mrz checksum — the lines were not read or the checksums do not match, cropped — the document is cropped. The web widget shows prompts already during capture.

The MRZ is read as part of document recognition: you receive both the zone lines and the fields of the visual zone in one response. There is no separate MRZ-only mode.

A passport scanner is a device at a desk that reads a document with backlighting and suits cases when the client comes in person. MRZ OCR works with a photograph: the client photographs the document with a phone on a website or in an app, and the data arrives through the API without any equipment.

There is no separate charge for the MRZ: reading and checksum verification are included in document recognition — from 16 ₽ with anti-fraud. The first month is a free test.

In Russia: in the NeuroVision cloud or on your servers when installed in your perimeter. Processing complies with 152‑FZ; in the cloud, original images are stored for 3 months free of charge and then at the tariff rate, and with an installation on your side they never leave your infrastructure.