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.
Need more testing? Create a free account to get 200 free credits (equals 100 Passport scans).

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

PYTHON EXAMPLE
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

Country Tutorial

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.

Python · Passport
Country Tutorial

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.

Node.js · Passport
Country Tutorial

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.

Python · Passport
Country Tutorial

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.

Python · Passport
Country Tutorial

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
Tutorial

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.

Node.js · Passport
Country Tutorial

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.

Python · Passport
Country Tutorial

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.

Python · Passport
Country Tutorial

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.

Node.js · Passport
Tutorial

Nanonets Alternative: Invoice OCR API

Nanonets compared with the StructOCR REST API for invoice extraction: deployment, pricing model, and when each fits.

Invoice

Technical Comparisons & Integrations

Explore platform integrations and competitive analysis

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.

Instant Access Cancel Anytime No Credit Card