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
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 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 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: < 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
- •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.
You May Also Like
Related tutorials, platform guides, and comparisons
Malaysia MyKad OCR with Node.js SDK
Extract identity number, names, dates and other visible fields from MyKad with the StructOCR Node.js SDK and Express.
UAE Emirates ID OCR with Node.js SDK
Extract Emirates ID number, names, dates and other visible fields from Emirates ID with the StructOCR Node.js SDK and Express.
Philippines PhilID OCR with Node.js SDK
Extract PhilSys Card Number, names, dates and other visible fields from Philippine Identification Card (PhilID) with the StructOCR Node.js SDK and Express.
South Africa Smart ID OCR with Node.js SDK
Extract identity number, names, dates and other visible fields from South African Smart ID card with the StructOCR Node.js SDK and Express.
India Aadhaar OCR with Node.js SDK
Extract Aadhaar number, names, dates and other visible fields from Aadhaar card with the StructOCR Node.js SDK and Express.
Indonesia KTP OCR with Node.js SDK
Extract NIK, names, dates and other visible fields from Kartu Tanda Penduduk (KTP) with the StructOCR Node.js SDK and Express.
Pakistan CNIC OCR with Node.js SDK
Extract CNIC number, names, dates and other visible fields from Computerized National Identity Card (CNIC) with the StructOCR Node.js SDK and Express.
Uganda National ID Card OCR Python SDK
Python Tutorial: Automate KYC in Uganda. Extract data from National ID Card using StructOCR Python SDK. Supports native text and MRZ extraction.
Tanzania NIDA Card OCR Python SDK
Python Tutorial: Automate KYC in Tanzania. Extract data from NIDA Card using StructOCR Python SDK. Supports native text and MRZ extraction.
Tunisia CIN (Carte d'Identité Nationale) OCR Python SDK
Python Tutorial: Automate KYC in Tunisia. Extract data from CIN (Carte d'Identité Nationale) using StructOCR Python SDK. Supports native text.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add National ID OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Bolt.new app. Build KYC and identity verification flows right in your browser.
Add National ID OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API using the Cursor AI code editor. Build KYC and identity verification flows rapidly.
Add National ID OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Lovable.dev app. Build KYC and identity verification flows with zero backend.
Add National ID OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a Replit application. Build KYC and identity verification flows using Replit Agent and Secrets.
Add National ID OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR National ID scanner API into a v0 by Vercel app. Build KYC and identity verification flows with zero backend.
Add Driver's License OCR to Your v0 App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a v0 by Vercel app. Build car rental and mobility onboarding flows with zero backend.
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.