MRZ Scanner SDK

MRZ Scanner SDK for Passports and ID Documents

Integrate on-device MRZ scanning into mobile and web applications with barKoder. The MRZ Scanner SDK reads machine-readable zones from passports, identity cards, visas and residence permits and returns structured document data for onboarding, identity verification and document-processing workflows.

mzr hero

Add an MRZ reader to your app

MRZ scanning is a decoder in the barKoder SDK. Turn on the ID document decoder, point the camera at the passport or ID card, and read the parsed fields from the result. Processing runs on the device. You need a license key with MRZ enabled.

Enable MRZ scanning

Web, with the barkoder-wasm-ocr package from npm:

JavaScript
          Barkoder.setEnabledDecoders(Barkoder.constants.Decoders.IDDocument);
        

iOS:

Swift
          private func setActiveBarcodeTypes() {
          guard let decoderConfig = barkoderView.config?.decoderConfig else { return }
          decoderConfig.idDocument.enabled = true
          }
        

Where the MRZ Scanner SDK runs

The barKoder MRZ module was released in late October 2024 with SDK version 1.5. MRZ scanning is now documented for native mobile, the web, C# and every cross-platform framework barKoder supports.

What is a machine-readable zone?

A Machine Readable Zone (MRZ) is the section of an identity document that holds personal data in a standardized format. You find it on passports, ID cards, visas, residence permits and other travel documents, usually at the bottom of the page, as two or three lines of text in the OCR-B font.

The format is defined by the International Civil Aviation Organization (ICAO) in Doc 9303 for Machine Readable Travel Documents. Only the digits 0-9, the capital letters A-Z and the filler character < are allowed. The filler stands for spaces and padding. Surname and given names are separated by <<, and letters with diacritics are transliterated, for example Ü to UE and ß to SS.

Since 2010, ICAO has required member states to issue only machine-readable passports, and non-MRZ passports became invalid for international travel after November 2015. That is why one MRZ reader covers so many documents.

ID with a 3 line MRZ
An ID card with a 3-line MRZ
ICAO 9303 MRZ formats the scanner reads
Format Used on MRZ size
TD3 Passport booklets (the identity page) 2 lines of 44 characters
TD2 Medium-sized cards, some visas and older ID cards 2 lines of 36 characters
TD1 Credit-card sized documents: national ID cards, passport cards, some driver's licenses 3 lines of 30 characters
MRV-A Machine-readable visas 2 lines of 44 characters
MRV-B Machine-readable visas 2 lines of 36 characters

What the passport MRZ scanner returns

The MRZ looks like a jumble of letters, but every field sits in a fixed position and the critical ones carry check digits.

Fields in every MRZ

  • Document type (P for passport, V for visa)
  • Issuing country or authority
  • Surname and given names
  • Document number
  • Nationality
  • Date of birth
  • Sex
  • Expiration date
  • Optional personal number
  • Check digits

On Android and iOS, the result can also include images: the whole document, the holder's photo and the signature.

How check digits work

Each character gets a value: 0-9 as themselves, A-Z as 10-35 and < as 0. The values are multiplied by the repeating weights 7, 3, 1, summed, and the sum modulo 10 is the check digit.

Document number, date of birth and expiration date each have their own check digit, and a final overall check digit covers the combined fields. A mismatch means the MRZ was read incorrectly or altered.

Passport with a 2-line MRZ code
TD3 passport Line 1: document type, issuing country and name. Line 2: document number, nationality, birth date, sex, expiry, personal number and their check digits.
VISA with a 2-line MRZ code
Visa Two lines like a passport, with different lengths for the name and optional data.
How is data extracted from a MRZ code
From MRZ to fields The scanner locates the zone, reads the text and splits it into labeled fields.

Scanning and parsing are two steps. This page covers the MRZ Scanner SDK, which captures the zone with the camera. The MRZ parser turns the zone into structured fields with check digit and formatting validation.

MRZ scanning on a phone or in the browser

Reading an MRZ used to need a dedicated reader. With the MRZ Scanner SDK, the device camera does the job.

  1. Point The user holds the photo page flat with the MRZ lines in view.
  2. Locate The SDK finds the two or three high-contrast OCR-B lines in the camera frame.
  3. Read On-device OCR extracts the characters.
  4. Parse The text is split into fields and the check digits are validated.

Watch barKoder's MRZ module scan passports and ID cards in real time.

barKoder uses machine learning to detect the document features in the image, then OCR to read the zone.

Video: barKoder MRZ scanning demo on YouTube
barKoder MRZ module on YouTube

Why teams choose barKoder as their MRZ reader

Data security illustration

Data security

barKoder doesn't collect personal information. The SDK has to process what is in the MRZ, such as name, date of birth, personal number and document number, but all processing happens on the device. Any communication you request uses encrypted connections.

Graphic depicting high performance with speed indicators and performance bars, showcasing the fast and reliable MRZ and barcode scanning capabilities of barKoder.

High performance

Scanning is much faster than typing and removes typing errors. Results come back almost as soon as the camera points at the document. Average scan time is under half a second.

Visual showing a mobile device operating offline with connectivity icons crossed out, highlighting barKoder’s ability to perform MRZ and barcode scanning without internet access.

Works offline

The MRZ is read in real time on the device, without an internet connection, so the data never passes through external servers unless your app sends it. If you need data on your servers, you control the transfer on both ends.

Illustration symbolizing cost reduction, featuring coins and downward arrows representing efficiency and savings through barKoder’s MRZ scanning technology.

Lower cost

Phones and tablets replace external passport readers, which cuts equipment and training costs. Fewer failed reads mean fewer failed transactions.

Where an MRZ scanner SDK fits

MRZ was built for border control and is now used wherever an app needs a fast, reliable read of an official ID.

What to plan for

Devices and SDK size

  • The MRZ models for machine learning and OCR make the SDK larger.
  • Older hardware without ML acceleration can be slower.
  • iPhone 7 is the oldest iOS device tested and confirmed working. Devices with a dedicated neural engine perform better.
  • On the web, use the barkoder-wasm-ocr package instead of barkoder-wasm.

What MRZ data proves

  • Check digits confirm the zone was read correctly and is internally consistent.
  • They don't prove that the document is genuine or that it belongs to the person presenting it.
  • Add the identity checks your industry or regulator requires.

MRZ scanning on mobile, web and desktop

The MRZ Scanner SDK is documented for Android, iOS, the Web SDK, C# and every cross-platform framework. Enable the ID document decoder and read the fields from the scan result.

  • 7 native & desktop SDKs
  • 6 cross-platform integrations
  • One consistent scanning core

MRZ scanning in production

Lotos Tourist by Datalab Montenegro

Tourism · Montenegro · Android and iOS

Under a dayto integrate the SDK

The Lotos Tourist app registers guests by scanning ID documents. The MRZ scanner turned a slow, error-prone step into a one-click process, with faster check-ins and reliable scans on older Android devices too.

Read the Lotos Tourist story →

Try barKoder on your phone or in your browser

Install the free barKoder demo app, or open the web demo, and scan your own barcodes before you integrate the SDK.

iPhone and iPad

barKoder demo app for iOS

Scan with your camera, or point it at the QR code to open the App Store.

Download on the App Store
QR code linking to the barKoder demo app on the App Store

Android phones and tablets

barKoder demo app for Android

Scan with your camera, or point it at the QR code to open Google Play.

Get it on Google Play
QR code linking to the barKoder demo app on Google Play

Any modern browser

barKoder web demo

Runs the Web SDK in your browser, on desktop or mobile, with nothing to install.

Open the web demo
QR code linking to the barKoder web demo

Test with known samples. Print or display the testing sheet and scan each 1D and 2D barcode with the demo app. The data sheet summarizes the SDK for your team.

MRZ scanner SDK questions

What does an MRZ scanner SDK do?

It lets your app read the machine-readable zone of a passport, ID card, visa or residence permit with the device camera. barKoder's MRZ Scanner SDK locates the zone, reads it with on-device OCR, validates the check digits and returns the document data as fields.

Does the MRZ scanner work in web applications?

Yes. The Web SDK reads MRZ through the barkoder-wasm-ocr package, which is barkoder-wasm with MRZ scanning added. Enable the IDDocument decoder as shown in the Web MRZ example, or try the web MRZ demo first. No native plugin is needed.

Which documents and MRZ formats are supported?

Passports (TD3), ID cards (TD1 and TD2) and machine-readable visas (MRV-A and MRV-B), as defined in ICAO Doc 9303. That covers passports, national ID cards, visas and residence permits that carry an MRZ.

What is the difference between the MRZ scanner and the MRZ parser?

The MRZ Scanner SDK captures and reads the zone with the camera. The MRZ parser turns the text into structured fields such as name, document number, nationality, date of birth, sex and expiry, with check digit and formatting validation.

Is MRZ data sent to a server?

No. Scanning runs locally on the device and barKoder doesn't store personal information from scans. The SDK goes online only for the license check, at least once every 30 days.

Can the SDK extract the photo and signature from a passport?

Yes. On Android and iOS, the MRZ result can include the main image, the document image, the holder's picture and the signature. The Android MRZ example shows how to read them.

Does a valid MRZ prove the document is genuine?

No. Check digits show that the MRZ was read correctly and is internally consistent. They don't establish that the document is authentic or that it belongs to the person holding it, so build further checks around your requirements.

How do I get a developer license for MRZ scanning?

Register and generate a free 30-day trial license, which covers up to 25 devices. For production, see SDK pricing or request a quote. MRZ scanning needs a license key with MRZ enabled.

Add passport and ID MRZ scanning to your app

Test the MRZ Scanner SDK on your own documents with a free 30-day trial, or talk to an SDK expert about your onboarding or verification workflow.