Ocrideu
Reads the machine-readable data of European identity documents: the MRZ of ID cards and passports (ICAO 9303, TD1/TD2/TD3), plus QR codes and barcodes.
What it does
Ocrideu is a JavaScript/Node.js library that extracts the machine-readable information from European (EU/EEA) identity documents. It reads the Machine-Readable Zone (MRZ) of ICAO 9303 documents, in all three shapes: TD1 (the three-line 30-character zone of most ID cards), TD2 (two lines of 36) and TD3 (the two-line, 44-character zone of passports). It also reads the QR codes and barcodes printed on some documents.
It is most useful with a picture of the back of an identity card, or the data page of a passport, because that is where European documents carry their machine-readable data. Before reading, the library automatically rotates the image upright, optimises it for clarity, crops it to the document borders when it has really found a card and corrects the most common OCR mistakes against the check digits of the MRZ itself.
Install
npm i @tuchsoft/ocrideuUsage
import { parse } from '@tuchsoft/ocrideu';
import { readFileSync } from 'fs';
const image = readFileSync('id-card-back.jpg');
const result = await parse(image);
console.log(result.mrz); // parsed MRZ fields
console.log(result.codes); // QR and barcode payloads
console.log(result.side); // 'front' | 'back'
console.log(result.is_document); // { value, confidence }The parse() function accepts a Buffer and an optional options object that controls MRZ correction, image optimisation, barcode and QR scanning, face detection and the detection thresholds. Every capability can be tuned or turned off, and the return value includes timing metrics and image hashes if you need them.
What it returns
Version 2 returns one structured object: { mrz, country, profile, side, codes, is_document, portrait, image, hashes, expired, execution }. That is the MRZ fields (document number, issuing state, birth and expiry dates, name), the detected barcodes and QR codes, the side of the document, the document verdict with its confidence, an optional base64 portrait, and per-stage execution timings.
What changed in 2.0
Version 2 is a breaking release: parse() no longer returns the flat object of version 1, and there is no compatibility shim. It was built the other way round from version 1: first the benchmark suite and a recorded baseline, then one measured change at a time. On our main suite of 98 images the recognition of the document side went from 66.7% to 98.5%, barcode and QR reading from 0 to 50% up to 76-86%, and fatal crashes from 5 to 0; on a suite of 57 deliberately hard frames the MRZ went from 14.8% to 63.0%.
- Passport support: TD2 and TD3 MRZ, plus the German (
D) issuing state. - A smarter crop: the image is only warped to card proportions when the detected contour really looks like a card, which is what rescued passports.
- Side from the portrait, not from any detected face, so holograms no longer flip a back to a front.
- No more fatal crashes from the barcode library: the buffer size it is fed is computed rather than guessed.
- Honest confidence on the document verdict, and raw detector evidence on request.
The full story, including what the library still gets wrong, is in our write-up on building it on measurements.
What it does not do
Ocrideu does not read the human-readable fields and does not validate or verify the authenticity of a document. Its only job is to parse the machine-readable data that is already printed on the card, which makes it a fast first step for onboarding, form pre-filling and identity-data capture workflows, never a replacement for a real identity check.
Built for AI assistants too
This site works with AI assistants as well as with people. Every article, plugin and page of documentation is published in a machine-readable form, and an assistant can search our content, check which Moodle version a site is running, contact our team, or request a free temporary Moodle 5.3 platform. The full list is at llms.txt, and the same index as a page at llms.html.