The Node.js SDK for Mission-Critical Passport OCR
Achieve 99.8%+ accuracy and sub-second latency for parsing ICAO 9303 compliant Machine Readable Zones (MRZ).

Why Passport OCR is Difficult
Implementing reliable passport OCR is non-trivial. Open-source tools like Tesseract fail on low-quality scans due to image artifacts like glare, shadows, and inconsistent lighting. Passports are often photographed at an angle, requiring computationally expensive deskewing and rotation correction. The Machine Readable Zone (MRZ) itself follows the strict ICAO 9303 standard, which includes complex check digit validation logic. Maintaining custom RegEx patterns to parse this zone is brittle and fails to adapt to minor variations across jurisdictions. These challenges lead to high error rates, manual review queues, and significant engineering overhead.
Enterprise-Grade Extraction with StructOCR
StructOCR simplifies document processing by replacing complex pipelines with a single API call. Our service leverages pre-trained Deep Learning models optimized for identity documents, including a robust passport mrz ocr api. This API automatically handles image pre-processing such as perspective correction, denoising, and glare removal. Unlike traditional OCR solutions that return unstructured text, StructOCR provides standardized JSON output with validated fields conforming to the ICAO 9303 standard. This capability is crucial for applications managing international borders, as it eliminates manual parsing and validation, delivering production-ready data directly to your system.
Production Use Cases
- Digital Onboarding (KYC): Reduce drop-off rates by pre-filling user data from Passports in < 2 seconds.
- Fraud Prevention: Detect tampered fonts or mismatched MRZ checksums automatically.
- Global Compliance: Handle Passports from 200+ jurisdictions without custom rules.
Live Demo: Passport scanner
No registration required. Upload a file to test the extraction.
Drop files here or click to browse
JPG · PNG · WebP · up to 500 files · max 4.5 MB each
Implementation: Node.js SDK
The official Node.js SDK simplifies passport extraction. It handles file upload and parses both MRZ and Visual Inspection Zone (VIZ) data fields automatically.
Prerequisite: npm install structocr
const StructOCR = require('structocr');
// 💰 Save 30%+ vs competitors. Get 200 free credits instantly:
// 👉 https://structocr.com/register
// Initialize the client with your API key
const client = new StructOCR('YOUR_API_KEY_HERE');
async function scanPassport() {
// Note: Supports JPG, PNG, WebP (Max 4.5MB)
const imagePath = './passport.jpg';
try {
console.log(`Scanning passport: ${imagePath}...`);
// The SDK handles file reading and the API call
const result = await client.scanPassport(imagePath);
if (result.success && result.data) {
const data = result.data;
console.log('✅ Extraction Successful!');
// Basic Identity (MRZ + VIZ)
console.log(`Passport #: ${data.passport_number}`);
console.log(`Name: ${data.given_names} ${data.surname}`);
console.log(`Nation: ${data.nationality} (${data.country_code})`);
// Visual Zone Specifics (Unique to StructOCR)
console.log(`Birth Place:${data.place_of_birth}`);
console.log(`Issued At: ${data.place_of_issue}`);
// Dates
console.log(`DOB: ${data.date_of_birth} (${data.sex})`);
console.log(`Expiry: ${data.date_of_expiry}`);
} else {
console.error('❌ Extraction Failed:', result.error || 'Unknown Error');
}
} catch (error) {
console.error('An unexpected error occurred:', error.message);
}
}
scanPassport();Technical Specs
- •Latency: < 4s (Average)
- •Uptime: 99.9% SLA
- •Security: AES-256 Encryption & SOC2 Compliant
- •Input: JPG, PNG, WebP (File Path)
- •Max File Size: 4.5MB
- •Output: JSON (Structured Data)
Key Features
- •Visual Extraction (VIZ): Parses non-MRZ data fields like Place of Birth and Issuing Authority.
- •Global Support: Optimized for 195+ countries, handling complex backgrounds and holograms.
- •Date Normalization: Returns all dates (Birth, Issue, Expiry) in a standardized YYYY-MM-DD format.
Sample JSON Output
StructOCR returns a normalized JSON object, regardless of the input image angle or quality.
{
"success": true,
"data": {
"type": "passport",
"country_code": "USA",
"nationality": "UNITED STATES",
"passport_number": "E12345678",
"surname": "DOE",
"given_names": "JOHN",
"sex": "M",
"date_of_birth": "1990-01-01",
"place_of_birth": "NEW YORK, USA",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2030-01-01",
"place_of_issue": "PASSPORT AGENCY"
}
}Frequently Asked Questions
How does StructOCR compare to AWS Textract or Google Vision?
Generic OCR services like AWS Textract and Google Vision are designed to extract raw lines of text from an image. They do not understand the document's structure. You are still responsible for parsing those lines, validating checksums, and mapping 'DOE' to a 'surname' field. StructOCR is a specialized API that performs both OCR and data structuring, returning validated, labeled fields like `surname`, `date_of_birth`, and `passport_number` directly.
Do you store the uploaded images?
We do not store customer images. All data is processed in-memory (RAM) and is purged immediately after the API request is completed. We are a SOC2 compliant provider.
How to handle blurry images?
Our API includes an advanced image pre-processing engine. It automatically attempts to correct blur, adjust contrast, and remove noise before the OCR model analyzes the image, significantly increasing success rates on sub-optimal inputs.
You May Also Like
Related tutorials, platform guides, and comparisons
Greece Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Greece passports.
Norway Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Norway passports.
Kazakhstan Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Kazakhstan passports.
Irish Passport OCR with Node.js SDK
Use the StructOCR Node.js SDK and TypeScript + Express to extract visible identity, validity and MRZ fields from Irish passports.
Tanzania Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Tanzania passports.
Czech Republic Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Czech Republic passports.
New Zealand Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from New Zealand passports.
Nigeria Passport OCR with Node.js SDK
Use the official StructOCR Node.js SDK with TypeScript and Express to extract structured MRZ and VIZ data from Nigeria passports.
Nigeria Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Nigeria passports with a server-side integration.
New Zealand Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from New Zealand passports with a server-side integration.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Heavy KYC SDKs vs. StructOCR Passport API for Mobile Apps
Discover why modern app developers are abandoning bulky on-device OCR SDKs in favor of lightweight, edge-deployed Passport APIs.
Add Passport OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Lovable.dev app through a secure server-side function for travel and KYC flows.
Add Passport OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a Replit application. Build travel, hospitality, and global KYC flows using Replit Agent and Secrets.
Tesseract & PassportEye vs. StructOCR Passport API
A technical evaluation for developers deciding between open-source MRZ scanners and a dedicated cloud-based Passport OCR API.
Add Passport OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR Passport scanner API into a v0 by Vercel app through a secure Next.js server route.
AWS Textract vs. StructOCR API for Indian Passport Back Page Extraction
Why generic OCR fails at parsing the back page of Indian passports, and how a dedicated KYC API instantly extracts structured addresses, PIN codes, and family details.
From tutorial to production in 5 minutes.
You've seen the code. Now get your API key, grab your 200 free credits, and see it work with your own images. No credit card required.