Automated CPF Extraction from Brazilian Driver Licenses
Bypass manual data entry for LatAm eKYC. Instantly parse the CPF (Tax ID), RG, and other crucial identity fields directly from a Carteira Nacional de Habilitação (CNH) image. Upload your driver's license photo below to test the extraction accuracy for free.

Why Extracting CPF from a CNH is Challenging
For businesses expanding into Brazil, capturing the CPF (Cadastro de Pessoas Físicas) is mandatory for tax, banking, and identity verification. However, extracting a CPF from a driver's license (CNH) isn't as simple as reading text. The CPF is printed in a dense block of numbers, often adjacent to the RG (State Identity Number) and the card's security registration numbers. Generic text-recognition tools frequently mix these strings up or fail to recognize the strict XXX.XXX.XXX-XX format when processing low-light or angled smartphone uploads. To understand how our purpose-built identity models solve this localization problem, explore our core driver license OCR infrastructure.
Precision CPF Parsing via API
Our API doesn't just read characters; it understands the topographical layout of the Brazilian CNH. By utilizing advanced semantic Key-Value mapping, it isolates the CPF with 99%+ accuracy, converting it into a clean, database-ready JSON format. The entire system operates on Cloudflare's global edge network, ensuring ultra-low latency for requests originating anywhere in South America. Better yet, integration is frictionless—you don't need to embed heavy SDKs into your frontend. You can test the accuracy immediately using the free image upload tool below.
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 for CPF Extraction
Web3 & Crypto Onboarding (eKYC)
Verify Brazilian traders instantly. Cross-reference the flawlessly extracted CPF with national federal databases to fulfill strict AML requirements in seconds. We also eliminate cross-border financial friction by allowing you to manage your API subscription using USDT/USDC. Explore our flexible pricing plans.
Mobility & Gig Economy
Streamline driver onboarding for ride-hailing and car-sharing platforms. Automatically parse the CPF alongside the driver's vehicle class authorizations to instantly approve new fleet operators. Read more about our mobility driver verification solutions.
Digital Banking & Fintech
Reduce friction during mobile account creation. Let users snap a picture of their CNH, and let our API automatically fill in the CPF, Full Name, and Date of Birth fields, drastically lowering abandonment rates.
Technical Specs
- Targeted Extraction: Dedicated logic cleanly separates the CPF (Tax ID) from the RG (Identity Document) and CNH Registration Number.
- Format Validation: Automatically validates and standardizes the CPF output to include correct punctuation (XXX.XXX.XXX-XX) or raw digits based on your preference.
- Edge Routing: Hosted on Cloudflare, bypassing legacy regional gateways to provide lightning-fast TTFB (Time to First Byte) in Latin America.
- Privacy First: Processes images entirely in memory with zero permanent data retention to ensure compliance with LGPD (Brazil's General Data Protection Law).
Key Features
- Complete Identity Coverage: Extracts full name, dates (DOB, Issue, Expiry natively converted to YYYY-MM-DD), and vehicle classifications.
- Parentage Extraction: Reliably captures the 'Filiação' section, extracting both the mother's and father's names into structured fields.
- Card Security Number: Captures the vertical red serial number (Espelho) on the card's edge for advanced fraud prevention checks.
Integration & AI Prompts
Integrate CPF extraction in minutes. Our endpoint natively accepts direct file uploads, public URLs, or Base64-encoded strings (with built-in data cleansing for illegal whitespaces). For detailed payload structures, consult our developer documentation.
import requests
import base64
# 1. Prepare Base64 Image of the CNH
with open("brazilian_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"
}
# Direct Base64 injection
payload = {
"img": base64_image
}
response = requests.post(url, headers=headers, json=payload)
result = response.json()
if result.get('success'):
data = result['data']
print(f"✅ Extracted CPF: {data['personal_number']}")
print(f"✅ Extracted RG: {data['extra_details']['rg_number']}")Standardized JSON Output
See how our API intelligently maps the Brazilian CPF directly to the universal `personal_number` key, ensuring your database structure remains consistent regardless of the country of origin.
{
"success": true,
"data": {
"type": "drivers_license",
"country_code": "BRA",
"region": "SC",
"document_number": "09876543210",
"personal_number": "234.567.890-12",
"surname": "PEREIRA",
"given_names": "CARLOS EDUARDO",
"sex": null,
"date_of_birth": "1982-11-20",
"place_of_birth": "FLORIANOPOLIS/SC",
"date_of_issue": "2024-05-10",
"date_of_expiry": "2029-05-09",
"date_of_first_issue": "2000-08-25",
"issuing_authority": "DETRAN SC",
"address": null,
"vehicle_class": "AB",
"extra_details": {
"fathers_name": "JOSE PEREIRA",
"mothers_name": "MARIA FERREIRA",
"rg_number": "3456789 SSP SC",
"card_security_number": "0987654321"
}
}
}Frequently Asked Questions
Can I test the CPF extraction before purchasing an API key?
Yes! You can use the free image upload tool at the top of this page to test the extraction accuracy with your own sample CNH images instantly.
Does the API differentiate between the CPF and the RG?
Absolutely. Our layout-aware models recognize the contextual labels ('CPF' vs 'DOC. IDENTIDADE') to ensure the CPF is mapped to `personal_number` and the RG is placed in `extra_details.rg_number`.
What image formats are supported for the upload?
The API supports standard image formats including JPEG, PNG, and WebP up to 4.5MB. You can transmit these as direct file uploads or pure Base64 strings.
Explore More Drivers-license Solutions
Brazilian CNH (Driver's License) OCR API
Extract CPF, RG, and identity fields from Brazilian Carteira Nacional de Habilitação (CNH) instantly. High-accuracy OCR API deployed on edge networks for fast LatAm eKYC.
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