The Definitive Node.js SDK for National ID Data Extraction
Achieve 99.8% extraction accuracy in under 1500ms via a Hybrid Vision AI & MRZ Validation engine.

Why National ID OCR is Difficult
Standard OCR tools like Tesseract fail on real-world ID documents due to their variability. Glare from holographic overlays, shadows from poor lighting, and skewed or rotated images from mobile captures consistently degrade accuracy. Parsing the Machine-Readable Zone (MRZ) requires not just reading characters, but also validating complex checksums. Furthermore, the layout and security features of National IDs differ significantly across jurisdictions, requiring a constantly updated and fragile set of RegEx patterns for each country. This high maintenance overhead and low reliability make generic OCR unsuitable for production-grade KYC systems.
Enterprise-Grade Extraction with StructOCR
StructOCR replaces brittle, open-source OCR pipelines with a specialized API for robust id card parsing. Our system leverages pre-trained deep learning models, specifically fine-tuned on millions of global identity documents, to locate and interpret data fields, facilitating kyc automation. Unlike Tesseract, our API includes automatic image pre-processing. It performs perspective correction (deskewing), glare removal, and denoising before extraction, ensuring high accuracy even with sub-optimal mobile captures. The result is a standardized, validated JSON output, abstracting away the complexity of parsing different ID layouts.
Production Use Cases
- Digital Onboarding (KYC): Reduce drop-off rates by pre-filling user data from National IDs in < 2 seconds.
- Fraud Prevention: Detect tampered fonts or mismatched MRZ checksums automatically.
- Global Compliance: Handle National IDs from 200+ jurisdictions without custom rules.
Live Demo: ID card 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
Ready to use this in production? Get 20 free API calls — no credit card needed.
Get 20 Free API Calls →Implementation: Node.js SDK
The official Node.js SDK abstracts the complexity of file handling and API requests. It automatically parses region-specific fields like CNP (Romania) or CPF (Brazil).
Prerequisite: npm install structocr
const StructOCR = require('structocr');
// 💰 Save 30%+ vs competitors. Get 20 free credits instantly:
// 👉 https://structocr.com/register
// Initialize the client with your API key
const client = new StructOCR('YOUR_API_KEY_HERE');
async function scanNationalId() {
// Note: Supports JPG, PNG, WebP
const imagePath = './id_card.jpg';
try {
console.log(`Scanning National ID: ${imagePath}...`);
// The SDK handles file reading and the API call
const result = await client.scanNationalId(imagePath);
if (result.success && result.data) {
const data = result.data;
console.log('✅ Extraction Successful!');
console.log(`Region: ${data.country_code} (Series: ${data.card_series})`);
console.log(`Name: ${data.given_names} ${data.surname}`);
console.log(`ID Number: ${data.document_number}`);
// Specialized field for National Identity Numbers (CNP, CPF, NIN)
console.log(`Personal #: ${data.personal_number}`);
console.log(`DOB: ${data.date_of_birth} (${data.sex})`);
console.log(`Address: ${data.address}`);
// Print Raw MRZ if available
if (data.additional_fields && data.additional_fields.mrz_line_1) {
console.log(`MRZ Line 1: ${data.additional_fields.mrz_line_1}`);
console.log(`MRZ Line 2: ${data.additional_fields.mrz_line_2}`);
}
} else {
console.error('❌ Extraction Failed:', result.error || 'Unknown Error');
}
} catch (error) {
console.error('An unexpected error occurred:', error.message);
}
}
scanNationalId();Technical Specs
- •Latency: < 5s (Average)
- •Uptime: 98.5% SLA
- •Security: AES-256 Encryption & SOC2 Compliant
- •Input: JPG, PNG, WebP (File Path)
- •Max File Size: 4.5MB
- •Output: JSON (Structured Data)
Key Features
- •Hybrid VIZ + MRZ AI: Cross-validates unstructured visual data against cryptographic MRZ checksums (TD1/TD2) for zero hallucination.
- •Specialized Numbers: Extracts region-specific IDs like CNP (Romania), CPF (Brazil), and NIN (Nigeria).
- •Multi-line Addresses: Intelligently reconstructs full addresses from fragmented lines on ID cards.
Sample JSON Output
StructOCR returns a normalized JSON object containing both Visual Zone (VIZ) extraction and raw Machine-Readable Zone (MRZ) lines.
{
"success": true,
"data": {
"type": "national_id",
"country_code": "ROU",
"nationality": "ROMANA",
"document_number": "123456",
"card_series": "KS",
"personal_number": "1920319123456",
"surname": "POPESCU",
"given_names": "ANDREI",
"sex": "M",
"date_of_birth": "1992-03-19",
"place_of_birth": "Jud. CS Mun. Reșița",
"address": "Jud. CS Orș. Bocșa Str. Nucilor Nr. 15",
"date_of_issue": "2020-05-10",
"date_of_expiry": "2030-05-10",
"issuing_authority": "SPCLEP Bocșa",
"additional_fields": {
"phone_number": null,
"tramite_number": null,
"ejemplar": null,
"mrz_line_1": "IDROU123456<0<<<<<<<<<<<<<<<<",
"mrz_line_2": "9203195M3005108ROU19203191234562",
"mrz_line_3": null
}
}
}Frequently Asked Questions
Do you support Machine Readable Zones (MRZ) on ID cards?
Yes! Our engine natively supports ICAO 9303 standard MRZ formats (TD1/TD2) found on many global ID cards. Our Hybrid architecture extracts both the raw MRZ lines and cross-validates them against the Visual Zone (VIZ) for maximum accuracy.
How does StructOCR compare to AWS Textract or Google Vision?
Generic OCR services like Textract or Vision return an unstructured array of text lines and their coordinates. Developers must build and maintain complex parsers to map this raw text to meaningful fields. StructOCR is a specialized model that directly returns a structured JSON object with pre-identified and validated fields, eliminating all post-processing logic.
Do you store the uploaded images?
No. All image data is processed in-memory and is purged immediately after the extraction process completes. We do not persist customer image data on our servers.
How to handle blurry images?
Our API includes an automated image enhancement engine that runs before the OCR process. It applies deblurring and sharpening algorithms to significantly improve the success rate on low-quality or out-of-focus images from mobile captures.
More OCR Tutorials
Node.js Shipping Container OCR API
Tutorial: How to use the StructOCR Node.js SDK to extract data from Shipping Containers. Includes code samples and JSON schema.
Node.js Driver License Verification API
Stop manual driver license checks. Our Node.js API delivers verified data in JSON within <5s, secured by AES-256 encryption and SOC2 compliance. Achieve 98.5% uptime.
Node.js HIN (Hull Identification Number) OCR API SDK
Tutorial: How to extract Hull Identification Numbers (HIN) using the StructOCR Node.js SDK. Learn to parse marine data in Express or serverless environments with 99% accuracy.
Node.js Invoice Parsing API
High-accuracy Node.js invoice parsing API for accounts payable automation. Extract line items, merchants, and financials into structured JSON output instantly.
Precise Data Extraction and Seamless
Integration with AI-powered OCR API.
Empower your solutions with automated data extraction by
integrating best-in class StructOCR via API seamlessly.
No credit card required • Full API access included