Skip to main content
Version: v8001

Scan a passport

Passports have a data page (the page with the photo) that contains two zones:

  • VIZ (Visual Inspection Zone): the biographical data printed in the upper half—name, nationality, date of birth, document number, and similar fields
  • MRZ (Machine Readable Zone): the two lines of OCR-formatted text at the bottom of the page, encoding the same core fields in a machine-readable format

BlinkID extracts both zones and cross-validates the data between them.

Default behavior​

By default, BlinkID scans only the data page (passportDataPageScanOnly: true). This is the correct setting for most use cases: the data page contains all the core biographical data.

Some passports have a second inner page (for example, a visa page) that additional data can be extracted from. To also scan this second page, set passportDataPageScanOnly to false and use automatic scanning mode. The SDK will then prompt the user to turn to the second page when relevant.

Scan the data page (default)​

No special configuration is needed—just initialize as normal and BlinkID will scan the passport data page.

import { createBlinkId } from "@microblink/blinkid";

const blinkId = await createBlinkId({
licenseKey: "your-license-key",
// passportDataPageScanOnly defaults to true
});

blinkId.addOnResultCallback((result) => {
console.log("Result:", result);
void blinkId.destroy();
});

Also scan the second page​

Set passportDataPageScanOnly to false to require a second-page scan for passports that support it.

import { createBlinkId } from "@microblink/blinkid";

const blinkId = await createBlinkId({
licenseKey: "your-license-key",
scanningSettings: {
documentCaptureModule: {
passportDataPageScanOnly: false,
},
},
});

Read biographical data (VIZ)​

The VIZ data is available in the aggregated top-level result fields, as well as in the per-side viz field of subResults.

blinkId.addOnResultCallback((result) => {
// Top-level aggregated fields
console.log("Full name:", result.fullName?.latin?.value);
console.log("Date of birth:", result.dateOfBirth?.originalString?.latin?.value);
console.log("Nationality:", result.nationality?.latin?.value);
console.log("Document number:", result.documentNumber?.latin?.value);
console.log("Date of expiry:", result.dateOfExpiry?.originalString?.latin?.value);
console.log("Sex:", result.sex?.latin?.value);

// Raw VIZ from the data page
const dataPage = result.subResults[0];
console.log("VIZ:", dataPage.viz);

void blinkId.destroy();
});

Read MRZ data​

MRZ data is available in subResults[0].mrz. It contains the same core fields as the VIZ, plus MRZ-specific fields like primaryId, secondaryId, opt1, and opt2.

blinkId.addOnResultCallback((result) => {
const mrz = result.subResults[0].mrz;
if (mrz) {
console.log("Document number:", mrz.documentNumber);
console.log("Nationality:", mrz.nationality);
console.log("Date of birth:", mrz.dateOfBirth.originalString);
console.log("Date of expiry:", mrz.dateOfExpiry.originalString);
console.log("Gender:", mrz.gender);
console.log("Primary ID:", mrz.primaryId);
console.log("Secondary ID:", mrz.secondaryId);
console.log("Raw MRZ:", mrz.rawMrzString);
console.log("MRZ verified:", mrz.verified);
}
void blinkId.destroy();
});

The verified field is true when all MRZ check digits are valid—a basic integrity check for the scanned MRZ.