France Carte Nationale d'Identité OCR Python SDK
Instantly extract data and validate cryptographic MRZ checksums from French IDs using our native Python library.

Parsing Carte Nationale d'Identité Challenges
Extracting information from French Carte Nationale d'Identité can be challenging due to variations in layout between different card versions (legacy vs. new biometric eID) and the presence of native French text and special characters, which require robust character recognition. Additionally, locating and strictly validating the Machine-Readable Zone (MRZ) is crucial to prevent document forgery.
Why StructOCR for France
Our model is specifically trained on a large dataset of French Carte Nationale d'Identité, enabling precise id parsing api capabilities. The StructOCR Python SDK provides a simple and intuitive interface, allowing you to integrate OCR functionality with just a few lines of code. It automatically handles image preprocessing, accurately identifies the 14 digits structure required for validation, and actively parses the embedded MRZ.
Common Use Cases in France
- Digital Onboarding: Verify users for Fintech apps in France, automatically matching VIZ data against the MRZ.
- Telecom Registration: Automate SIM card registration with Carte Nationale d'Identité.
- Hotel Check-in: Speed up guest registration workflows with automated MRZ scanning.
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
Python SDK Integration
Install the SDK via pip: `pip install structocr`. Then use the following code. The SDK maps visual fields and extracts the raw MRZ lines automatically.
Prerequisite: Python 3.6+ and `structocr` library installed.
from structocr import StructOCR
# 💰 Save 30%+ vs competitors. Get 200 free credits instantly:
# 👉 https://structocr.com/register
# Initialize with your API Key
client = StructOCR("YOUR_API_KEY_HERE")
def scan_france_id():
# Note: Supports JPG, PNG, WebP (Max 4.5MB)
# Target: Carte Nationale d'Identité
image_path = "france_national_id.jpg"
try:
print(f"Scanning {image_path}...")
# The SDK handles file upload and API communication
result = client.scan_national_id(image_path)
if result.get('success'):
data = result['data']
print("✅ France Extraction Successful!")
# Basic Identity
print(f"Region: {data.get('country_code')} (Series: {data.get('card_series')})")
print(f"Name: {data.get('given_names')} {data.get('surname')}")
print(f"ID Number: {data.get('document_number')}")
# Demographics
print(f"DOB: {data.get('date_of_birth')} ({data.get('sex')})")
print(f"Address: {data.get('address')}")
# Extract MRZ Data
additional = data.get('additional_fields', {})
if additional.get('mrz_line_1'):
print("\n🔍 MRZ Data Extracted:")
print(f"Line 1: {additional.get('mrz_line_1')}")
print(f"Line 2: {additional.get('mrz_line_2')}")
if additional.get('mrz_line_3'):
print(f"Line 3: {additional.get('mrz_line_3')}")
else:
print(f"❌ Extraction Failed: {result.get('error')}")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
scan_france_id()Technical Specs
- •Latency: < 4s (Average)
- •Uptime: 99.9% SLA
- •Security: AES-256 Encryption & SOC2 Compliant
- •Input: JPG, PNG, WebP (Max 4.5MB)
- •Output: JSON (Structured Data + MRZ Block)
Key Features
- •Native Script Support: Reads English and local French characters perfectly.
- •Hybrid VIZ + MRZ AI: Cross-validates unstructured visual data against MRZ checksums for zero hallucination.
- •Blur Detection: Automatically rejects blurry images.
- •Smart Crop: Removes background noise automatically, ideal for mobile submissions.
JSON Response Example
The SDK returns a Python dictionary matching this JSON structure, including the parsed visual data and the raw Machine-Readable Zone (MRZ).
{
"success": true,
"data": {
"type": "national_id",
"country_code": "FRA",
"nationality": "FRANÇAISE",
"document_number": "180675301234",
"card_series": "",
"personal_number": "",
"surname": "DUPONT",
"given_names": "JEAN-PIERRE",
"sex": "M",
"date_of_birth": "1990-05-15",
"place_of_birth": "LYON (69)",
"address": "10 Avenue des Champs-Élysées, 75008 Paris",
"date_of_issue": "2020-01-01",
"date_of_expiry": "2030-01-01",
"issuing_authority": "République Française",
"additional_fields": {
"tramite_number": null,
"mrz_line_1": "IDFRA180675301234<<<<<<<<<<<<<",
"mrz_line_2": "9005156M3001018FRA<<<<<<<<<<<4",
"mrz_line_3": "DUPONT<<JEAN<PIERRE<<<<<<<<<<<"
}
}
}Frequently Asked Questions
Does the SDK validate the MRZ on the Carte Nationale d'Identité?
Yes. Our engine extracts the MRZ lines (supporting both old TD2 and new biometric TD1 formats) and runs the standard ICAO 9303 checksum verification to ensure data integrity.
Does the Python SDK handle image uploads?
Yes, the SDK automatically handles base64 encoding and file uploads.
Is data stored?
No. Images are processed in-memory and deleted immediately.
You May Also Like
Related tutorials, platform guides, and comparisons
Côte d'Ivoire CNI (Carte Nationale d'Identité) OCR Python SDK
Python Tutorial: Automate KYC in Côte d'Ivoire. Extract French text, NNI, and validate TD1 MRZ from the ONECI CNI using StructOCR Python SDK.
Kenya National ID (Maisha Card) OCR Python SDK
Python Tutorial: Automate KYC in Kenya. Extract data, Maisha Namba (UPI), and validate TD1 MRZ from National ID (Maisha Card) using StructOCR Python SDK.
Ukraine National ID OCR Python SDK
Python Tutorial: Automate KYC in Ukraine. Extract data from National ID using StructOCR Python SDK. Supports native text and MRZ extraction.
Egypt ID OCR API & Python SDK
Python Tutorial: Automate KYC in Egypt. Extract data from National IDs using our SDK. Upload an image to test our ID OCR engine live for free.
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.
Python National ID OCR API
High-accuracy National ID OCR for Python. Upload an image for a free test! Get structured JSON output via our dedicated Python SDK. Automate KYC and data entry with 99%+ accuracy.
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.
Bangladesh Smart NID OCR Python SDK
Python Tutorial: Automate KYC in Bangladesh. Extract complex Bengali text and decode 2D barcodes from Smart NIDs using StructOCR Python SDK.
Saudi Arabia National ID & Iqama OCR Python SDK
Python Tutorial: Automate KYC in Saudi Arabia. Extract data from National IDs and Iqamas using the StructOCR Python SDK. Supports bilingual (Arabic/English) text, 10-digit ID numbers, and 3-line MRZ extraction.
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.
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.