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
Ready to use this in production? Get 20 free API calls — no credit card needed.
Get 20 Free API Calls →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.
Precise Data Extraction and Seamless
Integration with AI-powered OCR API.
Empower your solutions with automated data extraction by
integrating best-in class StructOCR via API seamlessly.
No credit card required • Full API access included