Skip to main content

MRZ Parsing Accuracy: A Step-by-Step How-To (2026)

Send an uncropped image to Didit ID Verification: it decodes the MRZ, validates check digits, cross-checks the visual zone and returns a status and warnings. $0.15 per check.

MRZ Parsing Accuracy: A Step-by-Step How-To (2026)

Contents

In this guide

Jump to the part you need.

This page is for teams that need the machine readable zone on a passport, ID card or residence permit decoded and checked, not just read. We decode MRZ inside Didit ID Verification at $0.15 per document check in a workflow, $0.20 per call on the standalone API. The caveat: an MRZ read is only as good as the image, so uncropped photos with all four corners visible are a prerequisite.

Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.

MRZ parsing with Didit at a glance
ItemDetail
OutcomeA decoded MRZ, validated check digits, a cross-check against the visual zone, and a status with warnings
EndpointPOST https://verification.didit.me/v3/id-verification/ for an existing image, or the ID Verification step inside a session
Price$0.20 per call on the standalone API, $0.15 per document check inside a workflow
Required inputfront_image, plus back_image for two-sided documents, max 5 MB per file, uncropped
Coverage14,000+ document types in 220+ countries, 54 capture languages
Signals of a bad readINVALID_MRZ, INCONSISTENT_DATA, EXPIRATION_DATE_NOT_DETECTED, COULD_NOT_RECOGNIZE_DOCUMENT
When a human decidesstatus is In Review, for example when the forgery check returned no usable score

Start free in the sandbox at business.didit.me, no sales call. The product behind this is ID Verification, and developers who want an AI assistant to drive the integration can connect Didit through the MCP server. Every price is on the pricing page.

What an MRZ parse has to get right

The machine readable zone is the fixed-width block of characters at the bottom of a passport data page or on the back of an ID card. ICAO Doc 9303 defines the format: a restricted character set, filler characters, and check digits at fixed positions. The zone carries the document number, issuing state, nationality, name, date of birth, sex and expiry date in a form no one has to re-key.

The two MRZ layouts you will meet most often, as ICAO Doc 9303 defines them
DocumentLayoutWhat the lines carry
Passport (TD3)44 characters over 2 linesLine 1: document code, issuing state, name. Line 2: document number and its check digit, nationality, date of birth and its check digit, sex, expiry date and its check digit, optional personal number and its check digit
ID card, residence permit, many driver's licenses (TD1)30 characters over 3 linesLine 1: document code and document number with its check digit. Line 2: date of birth with its check digit, sex, expiry date with its check digit, nationality. Line 3: name

Recognising the characters is the easy part. Getting them right is not:

  • Localisation. The zone has to be found and aligned before OCR. Glare on a laminate, a curled page or a passport photographed on a table pushes the lines out of frame.
  • Character set. The MRZ font is constrained, the images are not. A 0 and an O, a 1 and an I, an 8 and a B look alike at low resolution, and a generic OCR model does not default to the MRZ alphabet.
  • Check digits. Each line carries digits computed from the characters around them. A wrong digit does not just look odd, it proves that at least one character in that field is wrong.
  • Cross-zone agreement. The visual zone states one date of birth and the MRZ states another. Neither can be trusted alone, so both have to be read and compared.

The recommended method follows from this. Use a parser that decodes the MRZ, validates the check digits, compares the result with the visual zone, and returns every disagreement as a warning with a documented action. That is what Didit ID Verification does, and it is what our 4,000+ companies call when they need document data they can act on. The rest of this page is the procedure.

Prerequisites

  • A Didit API key, created in the Business Console at business.didit.me. Sandbox testing is free on every plan.
  • One or two document images, or a workflow with the ID Verification feature for user-facing capture. Accepted file types are tiff, jpg, jpeg, png, webp and pdf, max 5 MB per file.
  • A decision on your MRZ policy before the first call. invalid_mrz_action, inconsistent_data_action and expiration_date_not_detected_action each accept DECLINE or NO_ACTION.
  • Review capacity if you leave any of those groups at NO_ACTION, because a disputed MRZ then lands on a person.
  • A webhook endpoint that can verify the X-Signature-V2 header if you want decisions pushed to you instead of polled.

How to parse an MRZ with Didit, step by step

  1. Choose where the call runs. For an image you already hold, call POST https://verification.didit.me/v3/id-verification/. For a person capturing a document in your flow, add the ID Verification feature to a workflow, create a session with POST /v3/session/, and read id_verifications[] from GET /v3/session/{sessionId}/decision/. Both return the same report object, so the parsing rules you write apply to both.

  2. Prepare the images. Send the whole document and do not pre-crop, because the service detects, aligns and crops the document itself. Add back_image for ID cards, driver's licenses and residence permits.

  3. Set the MRZ actions before the first request. invalid_mrz_action=DECLINE declines a document whose MRZ check digits do not validate. inconsistent_data_action=DECLINE declines when the MRZ and the visual zone disagree. expiration_date_not_detected_action=DECLINE declines when no expiry date could be read. Leave a group at NO_ACTION and that risk becomes informational only.

  4. Send the request. This is the documented call:

    curl -X POST 'https://verification.didit.me/v3/id-verification/' \
    -H 'x-api-key: YOUR_API_KEY' \
    -F 'front_image=@./id_front.jpg' \
    -F 'back_image=@./id_back.jpg' \
    -F 'perform_document_liveness=true' \
    -F 'minimum_age=18' \
    -F 'expiration_date_not_detected_action=DECLINE' \
    -F 'invalid_mrz_action=DECLINE' \
    -F 'inconsistent_data_action=DECLINE' \
    -F 'preferred_characters=latin' \
    -F 'save_api_request=true' \
    -F 'vendor_data=user-123'
  5. Read status before you read a single field. Approved means no warning resolved to a decline. Declined means at least one did. In Review means the result cannot be decided automatically. Writing MRZ fields to your database before this check is how teams approve documents they should have rejected.

  6. Walk the warnings[] array. Each entry carries a risk code, a log_type of error, warning or information, and a long_description written to be shown to the person. Show the first error and stop the flow. Log the rest with the request_id.

  7. Keep the evidence and be able to re-fetch. With save_api_request=true, the default, the call is stored as an API-type session, request_id is a real session id, and the cropped document and portrait come back as short-lived media URLs. Download the images promptly instead of storing the URL. Re-read the report with:

    curl https://verification.didit.me/v3/session/{session_id}/decision/ \
    -H "x-api-key: YOUR_API_KEY"
  8. Take status.updated if the decision can change. Verify X-Signature-V2 over the sorted canonical JSON, reject a timestamp more than 300 seconds old, and re-fetch the decision rather than trusting a payload you could not verify. The legacy X-Signature-Simple header authenticates the envelope only, so re-fetch when you use it.

A person capturing an identity document in the Didit flow
Capture decides the parse: the whole document in frame, all four corners visible, even light across the MRZ lines.
The Didit flow analysing a captured document
After capture: classification, OCR of the visual zone, MRZ and barcode decoding, then the cross-checks.

Expected output

A 200 response carries request_id and one id_verification object. The three statuses you have to branch on:

What each id_verification.status means
StatusMeaningWhat you do
ApprovedNo warning resolved to a declineUse the fields, keep the warnings in your audit record
DeclinedAt least one warning resolved to a decline, either a fraud or hard-failure risk or a risk group you set to DECLINEShow the first warning and stop the flow
In ReviewThe result cannot be decided automatically, for example DOCUMENT_LIVENESS_NOT_COMPUTED when the forgery check returned no usable scoreRoute to your manual review queue, never approve automatically

Inside the object, mrz holds the decoded zone and the top-level fields hold what the visual zone said. A parse is trustworthy when the two agree and the check digits validate, which is exactly what the warnings report on. The full JSON schema is in the data models reference.

Two scope notes before you write the handler. MRZ_NOT_DETECTED, INVALID_DATE and PORTRAIT_IMAGE_NOT_DETECTED exist in workflow sessions but are never produced by the standalone endpoint, so do not code a branch for them on /v3/id-verification/. expected_details is the other way round: it is a session field, and the standalone call compares the document against nothing you already hold.

The ID document report inside a session in the Didit Business Console
The ID document report in the Business Console: extracted fields and warnings on the same screen as the decision.

Inputs and outputs

Request fields for the standalone ID Verification call
FieldRequiredWhat it does
front_imageYesThe document image. tiff, jpg, jpeg, png, webp or pdf, max 5 MB, uncropped with all four corners visible
back_imageFor two-sided documentsReverse side of an ID card, driver's license or residence permit
perform_document_livenessNo, default trueScreens the images for screen replays, printed copies and portrait manipulation
invalid_mrz_actionNoDECLINE or NO_ACTION when the MRZ check digits do not validate
inconsistent_data_actionNoDECLINE or NO_ACTION when the MRZ and the visual zone disagree
expiration_date_not_detected_actionNoDECLINE or NO_ACTION when no expiry date could be read
minimum_ageNoAge threshold, for example 18
preferred_charactersNoPreferred character set for the OCR output, for example latin
save_api_requestNo, default trueStores the call as an API-type session and returns media URLs
vendor_dataNoYour own identifier for the request, echoed back
Response fields you act on
FieldWhat it holds
statusApproved, Declined or In Review for this document
mrzThe decoded machine readable zone
document_type, document_subtypeThe classified document class and the registry subtype
full_name, date_of_birth, document_number, expiration_date, parsed_addressFields read from the visual zone, the ones the MRZ is compared against
barcodesAn array, always, and empty when the document produced no barcode output
warningsRisk objects with risk, log_type, short_description, long_description, additional_data and node_id
portrait_image, front_document_image, back_document_imageShort-lived media URLs for the stored images
request_idCorrelation id, and a real session id when save_api_request is true

Failure cases and recovery

What each failure looks like and what to do about it
SignalWhat happenedRecovery
HTTP 403, not enough creditsThe balance cannot cover the call, refused before any image processingTop up or add credit in the Business Console and retry
HTTP 400, COULD_NOT_RECOGNIZE_DOCUMENTThe document could not be processed at allAsk for a new capture with the whole document in frame
HTTP 400, multipart validationMissing back_image on a two-sided document, a file over 5 MB, or an unsupported extensionFix the form fields and the files before retrying
Declined with INVALID_MRZCheck digits do not validate, so at least one character is wrong or the zone was alteredRe-capture. If the same document fails twice on a clean image, treat it as a document integrity question, not an OCR question
Declined with INCONSISTENT_DATAThe MRZ disagrees with the visual zoneDo not auto-approve. Compare both zones by hand, because this is a pattern requiring manual document review
Declined with EXPIRATION_DATE_NOT_DETECTEDNo expiry date could be read and your action is DECLINEAsk for the reverse side if the date lives there, or route to review
Declined with COULD_NOT_DETECT_DOCUMENT_TYPEThe front image does not match a known official document design with high confidenceConfirm the document is a supported type before you ask the person to try again
In Review with DOCUMENT_LIVENESS_NOT_COMPUTEDThe forgery check returned no usable score, so the document is uncheckedRoute to manual review. This escalation is not configurable and never overrides a Declined
In Review on any other warningThe case needs a personSend it to your queue with the request_id and the first warning attached

Validation layers that stop a wrong character

Four checks stand between a misread glyph and a record in your database, and all four run inside the same call. The check digits catch a transcription error in the fields they cover. Date and number format validation catches a value that cannot exist, such as a month of 19. The cross-zone comparison catches a document where only one zone was edited. The duplicate warnings flag a document or a person already seen in your account, and they are a signal for review rather than proof of who owns the document. Any risk that is not in a decline group is informational and never declines on its own, so POSSIBLE_DUPLICATED_USER tells you something without stopping the flow.

On a session you can add one more layer before the parse happens. expected_details takes first_name, last_name, date_of_birth, nationality, id_country and expected_document_types, and a mismatch surfaces as a decision warning. An MRZ that parses cleanly but names a different person is then caught before approval instead of after onboarding.

What you pay for and where review starts

Parsing is billed per call, not per character, and the price depends on the route you take:

  • Standalone API. $0.20 per call, one ID Verification API credit per 200 response.
  • Inside a workflow. $0.15 per ID document check. A full KYC is $0.33 and is made of ID document $0.15 plus passive liveness $0.10 plus face match 1:1 $0.05 plus device and IP analysis $0.03.
  • NFC chip reading. $0.15 add-on per check when you read the passport chip instead of trusting the printed zone.
  • Sandbox. Free and unlimited. Nothing is charged in sandbox.

Each 200 response consumes one credit. A 403 for insufficient balance is rejected before image processing; check current billing terms for other errors.

The review boundary matters more than the price. Declined is terminal for the automated flow: show the warning, stop, and let the person start again. In Review means a person must decide, and a reviewer who overrides the result leaves a record in status_override alongside the automatic status it replaced. A parsed MRZ is not evidence that the document is genuine. Authenticity checks come before the extracted data, so keep the two decisions separate in your own records as well.

Worked cost example

Assume 20,000 document checks a month and one image pair per check, at published list prices.

  • Standalone API: 20,000 x $0.20 = $4,000.00.
  • Same checks inside a workflow with the ID Verification step: 20,000 x $0.15 = $3,000.00.
  • Difference: 4,000.00 minus 3,000.00 = $1,000.00 a month, which is the price of not owning the capture flow.
  • Full KYC instead of the ID step alone: 20,000 x $0.33 = $6,600.00, of which the ID document is 20,000 x $0.15 = $3,000.00.
  • Illustrative Scale plan-credit example. On Scale every Didit price carries 10% off, so $0.15 x 0.90 = $0.135 and 20,000 x $0.135 = $2,700.00 of usage. That usage is drawn from the $350.00 of plan credit added each month, leaving 2,700.00 minus 350.00 = $2,350.00 to come from your top-up balance. The $299.00 monthly subscription fee is separate from the usage balance and is not part of the $2,700.00.

Sources

The next step is one call with your own document. Create a free sandbox account at business.didit.me, no sales call, send a single uncropped front image, and read the MRZ, the status and the warnings in the console before you write any code.

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alberto Rosas

Co-founder and CEO

Alberto Rosas

Alberto Rosas

Co-founder and CEO

About Didit

Questions

Frequently asked questions

What is the MRZ on a passport or ID card?

The machine readable zone is the fixed-width block of characters at the bottom of a passport data page or on the back of an ID card, defined by ICAO Doc 9303. It holds the document number, issuing state, nationality, name, date of birth, sex and expiry date, plus check digits at fixed positions. Didit decodes it during ID Verification and returns it in the mrz field of the report.

How do I get an accurate MRZ parse?

Send an uncropped image of the whole document to POST https://verification.didit.me/v3/id-verification/, with a back_image for two-sided documents, and set invalid_mrz_action=DECLINE and inconsistent_data_action=DECLINE. The service reads the visual zone, decodes the MRZ, validates the check digits and compares the two zones. Read id_verification.status and id_verification.warnings before you use any field.

What does invalid_mrz_action do?

It controls what happens when the MRZ check digits do not validate. With DECLINE the response status becomes Declined with an INVALID_MRZ warning. With NO_ACTION the warning is informational and the status follows the other risks, so your review team owns that case. The same pattern applies to inconsistent_data_action and expiration_date_not_detected_action.

Why does a clean image still return INCONSISTENT_DATA?

Because the MRZ and the visual zone disagree, which is exactly what the cross-check exists to find. A clean image makes an OCR misread less likely, so a persistent disagreement points at the document rather than the photo. Compare the printed date of birth, document number and expiry date against the mrz payload by hand before you decide anything.

Is MRZ parsing only for passports?

No. Passports use a 44-character, two-line zone, while ID cards, residence permits and many driver's licenses use a 30-character, three-line format. Didit covers 14,000+ document types in 220+ countries and decodes the MRZ and any barcodes the document carries. Send back_image for the two-sided documents.

What image should I send for MRZ parsing?

An uncropped photo or scan of the whole document with all four corners visible, in tiff, jpg, jpeg, png, webp or pdf, up to 5 MB per file. Do not pre-crop, because the service detects, aligns and crops the document itself. Glare across the MRZ lines makes characters harder to read, so capture in even light and ask for a retake when the image is bright and unreadable.

Does the standalone API ever return MRZ_NOT_DETECTED?

No. MRZ_NOT_DETECTED exists in workflow sessions but is never produced by the standalone /v3/id-verification/ endpoint. There, an MRZ problem shows up through INVALID_MRZ or an extraction warning, and a document that cannot be processed at all returns 400 with COULD_NOT_RECOGNIZE_DOCUMENT.

How much does one MRZ parse cost?

$0.20 per call on the standalone ID Verification API and $0.15 per document check when ID Verification runs as a step inside a workflow. Each 200 response consumes one credit. A 403 for insufficient balance is rejected before image processing, so check current billing terms for other errors.

When does an MRZ result need a human?

When status is In Review, which happens for example when perform_document_liveness=true and the forgery check returns no usable score, flagged as DOCUMENT_LIVENESS_NOT_COMPUTED. Route those to your review queue and do not approve them. Declined is different: it is an automated decision you can show to the person and stop the flow.

Can I parse the MRZ without running the fraud checks?

Yes, set perform_document_liveness=false and the forgery check is skipped, so the status follows the remaining warnings. Do that only when you have another way to establish that the document is genuine. The parse proves the zone is internally consistent, not that the document was issued to the person holding it.

Can I check the parsed MRZ against data I already have?

Yes. On a session, send expected_details with first_name, last_name, date_of_birth, nationality, id_country and expected_document_types. Mismatches surface as decision warnings, so a clean parse that names a different person is caught before approval. For an existing image, compare the returned fields yourself before you store them.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.