Brazilian CNH (Driver's License) OCR API
Automate LatAm identity verification and eKYC. Instantly extract critical data—including CPF, RG, and parentage—from the complex layout of the Brazilian Carteira Nacional de Habilitação. Upload an image below to test for free.

The Complexity of Brazilian Identity Documents
Processing the Brazilian Carteira Nacional de Habilitação (CNH) is notoriously difficult for standard text-recognition tools. Unlike standardized North American or European IDs, the CNH contains highly localized data structures. Critical identifiers like the CPF (Tax ID) and RG (Identity number) are grouped alongside expansive fields for 'Filiação' (Mother and Father's names) and the 'Espelho' (card security number). Generic models frequently mislabel these fields or fail to parse the DD/MM/YYYY date formats accurately. To see how our dedicated identity models overcome these regional challenges, explore our comprehensive driver license OCR capabilities.
Edge-Routed Precision & Seamless Integration
Our CNH OCR engine is engineered to understand the exact topography of Brazilian licenses. We provide this as a pure REST API—meaning you don't need to bloat your mobile app or frontend with heavy SDKs, though lightweight wrappers are available for multiple languages. Because our infrastructure is deployed on Cloudflare edge networks, authentication and routing happen instantly, guaranteeing ultra-low latency for user requests originating in South America. The API natively accepts direct file uploads, Base64-encoded strings, or image URLs, providing absolute flexibility for your engineering team.
Live Demo: Driver License OCR 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
High-Growth Use Cases in LatAm
Web3 & Crypto Exchanges
Onboard Brazilian traders in seconds with instant eKYC. Extract the CPF perfectly every time to cross-reference with national databases. For global businesses, we eliminate cross-border friction by supporting subscription payments via USDT/USDC directly.
Mobility & Car Sharing
Verify drivers instantly without manual review. Ensure valid licenses and precise category classifications ('Categoria da Habilitação') to authorize vehicle access. Read more about our mobility driver verification solutions.
Fintech & Digital Banking
Scale your user acquisition pipeline. Users can simply upload a photo of their CNH, and our API parses the 'Nº REGISTRO' and parentage details flawlessly, significantly reducing abandonment rates during account creation. View our pricing plans to scale your operations.
Technical Specs
- CPF / RG Prioritization: Custom logic to correctly distinguish and separate the CPF format (XXX.XXX.XXX-XX) from the RG and local issuing state identifiers.
- Edge Routing Performance: API requests are processed via Cloudflare's global edge network, minimizing latency drastically for South American origins.
- Flexible Data Ingestion: Process direct file uploads, raw Base64 strings, or public image URLs with automatic MIME-type verification (preventing extension spoofing).
- Global Payments: API subscriptions support traditional credit cards alongside Web3-native crypto payments (USDT/USDC).
Key Features
- Extended Field Support: Beyond standard names, extracts local specific data like `fathers_name`, `mothers_name`, and `card_security_number`.
- Data Cleansing: Automatically strips illegal whitespace or newline characters from incoming Base64 payloads to prevent request failures.
- Date Standardization: Converts the local DD/MM/YYYY printed format strictly into ISO YYYY-MM-DD output.
Integration & AI Prompts
Ready to build? You can pass the document image directly via a Base64 string or file upload. For deep technical integration patterns, check our developer documentation. Try the prompt below in your AI coding assistant.
import requests
import base64
# Prepare Base64 Image of the Brazilian CNH
with open("cnh_sample.jpg", "rb") as image_file:
base64_image = base64.b64encode(image_file.read()).decode('utf-8')
url = "https://api.structocr.com/v1/driver-license"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
# Our API handles pure Base64 strings natively
payload = {
"img": base64_image
}
response = requests.post(url, headers=headers, json=payload)
result = response.json()
if result.get('success'):
data = result['data']
print(f"CPF Extracted: {data['personal_number']}")
print(f"License Number: {data['document_number']}")Standardized JSON Output
Notice how Brazilian-specific fields like the CPF are mapped to standard keys (`personal_number`), while unique local data (like parentage) is neatly organized inside the `extra_details` object.
{
"success": true,
"data": {
"type": "drivers_license",
"country_code": "BRA",
"region": "SP",
"document_number": "12345678900",
"personal_number": "111.222.333-44",
"surname": "SILVA SANTOS",
"given_names": "MARIA LUIZA",
"sex": null,
"date_of_birth": "1985-10-15",
"place_of_birth": "SAO PAULO/SP",
"date_of_issue": "2023-01-20",
"date_of_expiry": "2028-01-20",
"date_of_first_issue": "2005-06-10",
"issuing_authority": "DETRAN SP",
"address": null,
"vehicle_class": "B",
"extra_details": {
"fathers_name": "JOAO SILVA",
"mothers_name": "ANA SANTOS",
"rg_number": "1234567 SSP SP",
"card_security_number": "0000000000"
}
}
}Frequently Asked Questions
Do I need to install a heavy SDK to scan Brazilian licenses?
No. StructOCR is delivered as a pure, lightweight REST API. You only need to send an HTTP POST request containing the image (via Base64 or file upload). We do offer language wrappers if preferred, but they are completely optional.
Why does the JSON return 'null' for the 'sex' field on a CNH?
Unlike US or EU licenses, the modern Brazilian CNH often does not explicitly print the gender/sex of the driver on the physical card. Our API accurately reflects the visual reality of the document rather than hallucinating missing data.
Can the API read the security number (Espelho) printed on the side?
Yes. Our models extract the vertical red serial number printed on the far left edge of the CNH, returning it safely within the `card_security_number` field inside `extra_details`.
Explore More Drivers-license Solutions
Automated CPF Extraction from Brazilian Driver Licenses
Accurately extract the CPF (Tax ID) and RG from Brazilian driver licenses (CNH). Try our free image upload tool and integrate our fast, edge-routed OCR API.
Automated Document Discriminator (DD) Extraction
Instantly extract the Document Discriminator (DD) and audit numbers from US driver's licenses. Test our edge-routed OCR API for free using image uploads.
EU Driving Licence OCR API
Accurately parse numbered fields (1, 4a, 9) from European driving licences. Try our fast, edge-routed OCR API with a free image upload test.
Malaysian Lesen Memandu (Driving License) OCR API
Extract the IC number, identity fields, and vehicle classes from Malaysian driving licenses (Lesen Memandu). Test our edge-routed API with a free image upload.
Philippine LTO Driver License OCR API
Accurately extract data from Philippine LTO driver's licenses. Parse restriction codes, conditions, and identity fields via our edge-routed API. Test for free.
Indonesian SIM (Surat Izin Mengemudi) OCR API
Extract NIK, identity, and category data from Indonesian driver's licenses (Surat Izin Mengemudi). Test our low-latency, edge-routed API with a free image upload.
UK Driving Licence OCR & Field Extraction API
Accurately parse numbered fields (like Field 5 and Field 8) from UK driving licences. Try our fast, Cloudflare-routed OCR API with a free image upload test.
US Driver License Scanner API
Extract data from all 50 US state driver's licenses with our fast OCR API. Try our free image upload tool and easily parse the Document Discriminator (DD) and identity fields.
Technical Comparisons & Integrations
Explore platform integrations and competitive analysis
Add Driver's License OCR to Your Bolt.new App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Bolt.new app. Build car rental and mobility onboarding flows right in your browser.
Add Driver's License OCR using Cursor in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API using the Cursor AI code editor. Build car rental and mobility onboarding flows rapidly.
Add Driver's License OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Lovable.dev app. Build car rental and mobility onboarding flows with zero backend.
Add Driver's License OCR to Your Replit App in 5 Minutes
Step-by-step guide to integrating the StructOCR Driver's License scanner API into a Replit application. Build car rental and mobility onboarding flows using Replit Agent and Secrets.
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.
Add HIN OCR to Your Lovable.dev App in 5 Minutes
Step-by-step guide to integrating the StructOCR HIN (Hull Identification Number) scanner API into a Lovable.dev app. Build marine and boat management tools with zero backend required.
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.