MRZ Formats Explained: TD1, TD2, and TD3
The machine readable zone layouts used on passports and ID cards: line counts, line lengths, field positions, and where each format appears.
TD3: passports
Passport data pages use TD3: two lines of 44 characters. Line 1 holds the document type, issuing state, and name; line 2 holds the passport number, nationality, date of birth, sex, expiry date, optional data, and check digits.
Extracting It Automatically
When you read this data from photos, the Passport OCR API returns it as structured JSON, and you can apply the rules on this page as validation. Try it with the free scanner.
Where This Fits
- TD1: ID cards: Credit-card-sized ID cards use TD1: three lines of 30 characters, usually on the back of the card. Line 1 carries the document number, line 2 the dates and nationality, and line 3 the name.
- TD2: other documents: TD2 uses two lines of 36 characters and appears on some older ID cards and travel documents. Machine readable visas use their own MRV-A and MRV-B layouts.
- Filler and names: The < character fills unused positions and separates name parts: the surname is followed by <<, and given names are separated by single <. Names are transliterated to A–Z.
Extract It with the API
Read the document from a photo and validate the returned fields.
Prerequisite: Python 3.9+, `pip install requests`, and a STRUCTOCR_API_KEY
import base64
import os
import requests
with open("passport.jpg", "rb") as image_file:
image = base64.b64encode(image_file.read()).decode("ascii")
response = requests.post(
"https://api.structocr.com/v1/passport",
headers={"x-api-key": os.environ["STRUCTOCR_API_KEY"]},
json={"img": image},
timeout=30,
)
response.raise_for_status()
data = response.json()["data"]
print("passport_number:", data.get("passport_number"))
print("surname:", data.get("surname"))
print("given_names:", data.get("given_names"))
print("date_of_expiry:", data.get("date_of_expiry"))Technical Specs
- •Endpoint: POST https://api.structocr.com/v1/passport
- •Authentication: x-api-key request header
- •Inputs: JPG, PNG, or WebP as Base64 JSON; maximum 4.5MB
- •Price: 2 credits per successful request; failed requests are not billed
- •Free trial: 200 free credits on sign-up, no credit card required
Key Features
- •TD1: ID cards: Credit-card-sized ID cards use TD1: three lines of 30 characters, usually on the back of the card. Line 1 carries the document number, line 2 the dates and nationality, and line 3 the name.
- •TD2: other documents: TD2 uses two lines of 36 characters and appears on some older ID cards and travel documents. Machine readable visas use their own MRV-A and MRV-B layouts.
- •Filler and names: The < character fills unused positions and separates name parts: the surname is followed by <<, and given names are separated by single <. Names are transliterated to A–Z.
- •Validate after OCR: Apply these rules to API output before storing it.
Reference Summary
Key facts from this page in structured form, for quick lookup.
{
"TD3: passports": "Passport data pages use TD3: two lines of 44 characters.",
"TD1: ID cards": "Credit-card-sized ID cards use TD1: three lines of 30 characters, usually on the back of the card.",
"TD2: other documents": "TD2 uses two lines of 36 characters and appears on some older ID cards and travel documents.",
"Filler and names": "The < character fills unused positions and separates name parts: the surname is followed by <<, and given names are separated by single <."
}Frequently Asked Questions
Can I read only the MRZ?
You can, but the MRZ truncates long names and omits fields such as place of birth. Reading the visual zone too gives complete data.
Does StructOCR read ID cards with a TD1 MRZ?
Yes. The National ID API reads the card and returns structured fields; the passport API handles TD3 data pages.
You May Also Like
Related tutorials, platform guides, and comparisons
Portugal Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Portugal passports with a server-side integration.
Singapore 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 Singapore passports.
Finland Passport OCR: Extract Fields with Python
Extract visible fields from Finland passport images into JSON. Map identifiers, names and dates, with a review workflow for incomplete results.
Netherlands Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Netherlands passports with a server-side integration.
Tunisia 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 Tunisia passports.
Node.js Passport OCR API
High-accuracy Node.js Passport OCR API for parsing the MRZ. Upload an image for a free test! Get structured JSON output in seconds using our official Node.js SDK. Stop fighting Tesseract.
Thailand Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Thailand passports with a server-side integration.
Tanzania Passport OCR with Python SDK
Use the official StructOCR Python SDK and FastAPI to extract structured MRZ and VIZ data from Tanzania passports with a server-side integration.
Thailand 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 Thailand passports.
Nanonets Alternative: Invoice OCR API
Nanonets compared with the StructOCR REST API for invoice extraction: deployment, pricing model, and when each fits.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
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.
AWS Textract & Google Vision vs. StructOCR Passport API
How AWS Textract AnalyzeID, Google Cloud Vision OCR, and the StructOCR Passport API differ for passport data, quoting each vendor’s own documentation.
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.