· via dev.to (home feed)
FastMRZ 3 reads passport MRZ zones in pure Python, no Tesseract required
FastMRZ 3 replaces Tesseract with a bundled ONNX model trained on the 37-character MRZ alphabet, adding PDF input, batch processing and ICAO 9303 check-digit validation.

FastMRZ, an open-source Python library for reading the machine-readable zone (MRZ) on passports, ID cards and visas, has shipped version 3 — and the headline change is the removal of Tesseract. According to a post on dev.to by the library's author, Sivakumar Mahalingam, FastMRZ 3 now bundles its own ONNX-based text recogniser trained specifically on the MRZ character set, so the package installs as ordinary Python dependencies with no system-level OCR engine and no traineddata files to manage.
The setup problem it removes
The MRZ is the two- or three-line block of <-padded text at the bottom of a travel document. As the dev.to post explains, its alphabet is tiny: 37 possible characters (A–Z, 0–9 and the filler <), arranged in fixed layouts defined by the ICAO 9303 standard. Despite that narrow scope, most Python MRZ tools have historically wrapped Tesseract, a general-purpose OCR engine that must be installed at the operating-system level and configured with a special MRZ traineddata file. That setup has to be repeated across container images, serverless layers and CI runners, the author notes, and even then results can suffer on phone photos that are angled, out of focus or poorly lit.
Earlier versions of FastMRZ shared this weakness because they used Tesseract under the hood. Version 3 drops it completely.
A narrow recogniser instead of a general OCR engine
The post describes a four-stage pipeline. First, OpenCV contour detection combined with an ONNX model locates the MRZ region, even when the document is not perfectly aligned in the frame. Second, the strip is cropped, straightened and normalised. Third, a small ONNX model recognises the characters — because it only has to distinguish 37 symbols rendered in the OCR-B font rather than every glyph in every language, it can be smaller and more dependable for this specific job. Finally, every check digit defined by ICAO 9303 is verified and the fields are parsed into structured output.
Everything runs locally on CPU, so no document image leaves the machine — a point the author stresses given that the inputs are often passports. The dependency list is short: numpy, opencv-python-headless and pymupdf, installed with a single pip install fastmrz.
Inputs, validation and batch mode
Beyond file paths, the library accepts NumPy arrays such as camera frames, Base64 strings, raw bytes, scanned PDFs and already-extracted MRZ text, selected through an input_type parameter. Two helpers round out the API: validate_mrz, which checks check digits only, and get_mrz_image, which returns the rectified MRZ crop for audit logs or manual review.
Parsed results carry a status field: SUCCESS only when the format and every ICAO 9303 check digit are valid, FAILURE with a status_message naming the first problem otherwise. There is no exception handling to write — if no MRZ is present in the image at all, the response simply says so.
This release also introduces batch processing via get_details_batch. According to the post, results return in input order, work runs in parallel with worker count defaulting to the CPU count (capped at 8), and throughput is roughly 1.5x that of a plain loop on a 4-core CPU. An unreadable file does not halt the batch; its entry just comes back marked as a failure.
Supported document formats cover the common travel-credential layouts: TD1 for ID cards, TD2 for older ID cards and some visas, TD3 for passports, and the MRV-A and MRV-B visa formats.
For teams moving up from FastMRZ 1.x or 2.x, legacy tesseract_path and tessdata_path arguments are ignored with a FutureWarning, so cleanup can happen at whatever pace suits. A migration path from PassportEye, another Tesseract-dependent MRZ library, is also documented. The project is Apache-2.0 licensed, hosted on GitHub and published on PyPI, and the author is explicitly asking for redacted failure cases via issue tracker to keep improving the model.
Why it matters
Identity document parsing is quiet plumbing inside almost every KYC onboarding flow, hotel or airline check-in system and visa-processing back office, and the Tesseract installation tax has long been its most fragile part — especially in containers and serverless environments. By narrowing recognition to a 37-character, single-font alphabet, FastMRZ 3 trades generality for reliability and deployability, a pattern that tends to pay off wherever OCR meets a constrained domain. The fully local, CPU-only pipeline doubles as a privacy argument for anyone handling passports. The open question with any niche recognition model is real-world robustness, which is precisely what the author is inviting developers to test.
- #python
- #ocr
- #open-source
- #identity-verification
- #developer-tools