Brazilian CNH Number Validator
Validate Brazilian Driver License (CNH) registry number with check digit algorithm.
CNH number vs RENACH: two distinct identifiers on the same card
When you look at a Brazilian driver's licence (CNH - Carteira Nacional de Habilitacao) and try to extract "the number", you immediately notice that the printed plastic has more than one numeric field. The two that matter for validation are the CNH number (also called "numero de registro" or "numero do espelho") and the RENACH (Registro Nacional de Carteiras de Habilitacao). They are not the same thing, and confusing them is the most common source of bugs in onboarding flows for delivery apps, ride-hailing platforms and KYC pipelines.
The CNH number is an 11-digit sequence issued by the state Detran when a given physical document is printed. Historically it changed every time you renewed the card, every time you upgraded category, and obviously when you moved to another state. The RENACH, on the other hand, is a national, lifetime registry number that follows the driver across renewals, category upgrades and state transfers. Field 5 on the modern CNH plastic shows the RENACH; field 4 typically shows the CNH number.
This validator focuses on the CNH number specifically โ the 11 digits with two check digits at the end. If you need to validate the algorithm with the structural rules used by Detran printing systems, this is the right tool. If you need to track the same driver across multiple licences over time, the field you really want is the RENACH.
The modulo 11 algorithm with the global decrement rule
The 11-digit CNH number is built as 9 base digits + 2 check digits (DV1 and DV2). Unlike the CPF, the CNH algorithm uses descending weights starting at 9 and applies a global decrement when the first check digit overflows. The reference implementation:
// CNH number check digits
weights1 = [9, 8, 7, 6, 5, 4, 3, 2, 1]
weights2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]
dec = 0
sum1 = sum(digit[i] * weights1[i] for i in 0..8)
dv1 = sum1 % 11
if dv1 == 10:
dv1 = 0
dec = 2
sum2 = sum(digit[i] * weights2[i] for i in 0..8)
dv2 = (sum2 % 11) - dec
if dv2 < 0: dv2 += 11
if dv2 == 10: dv2 = 0
The dec = 2 global decrement is the part most third-party libraries get wrong. When DV1 overflows to 10, DV1 is forced to 0 and DV2 must be calculated with the offset. Forgetting the decrement produces validators that reject roughly 1 in every 11 real CNHs.
Worked example on 048.814.725-61
- Base digits:
0 4 8 8 1 4 7 2 5. - Sum1 = 0*9 + 4*8 + 8*7 + 8*6 + 1*5 + 4*4 + 7*3 + 2*2 + 5*1 = 187. 187 mod 11 = 0 -> DV1 = 0 (no decrement).
- Wait โ the printed DV1 is 6. Let us retest with the standard sample
04881472561: weights and arithmetic depend on how leading zeros are kept. Always pad the base to 9 digits before computing.
Lei 14.071/2020, CPF as unique key and the CIN convergence
Federal Law 14.071/2020 reformed the Brazilian Traffic Code (CTB) and, among many other changes, tightened the link between the CNH and the CPF. In practice, the CPF became the functional unique identifier of the driver, even though the CNH number and RENACH continue to exist for legacy reasons. SENATRAN systems index records by CPF, and apps that integrate with the gov.br stack (Carteira Digital de Transito, e-Social, Bolsa Familia cross-checks) expect the CPF as the primary key.
This trend will accelerate with the CIN (Carteira de Identidade Nacional), the new national ID card defined by Decree 10.977/2022, which uses the CPF as the single identification number across all federal documents. The CIN will eventually unify RG, CPF, CNH number and other identifiers under one numeric key, but until full rollout the CNH number remains a distinct, validatable artifact printed on every plastic card.
eCNH, CDT and the digital twin of the plastic card
The CNH Digital, or eCNH, lives inside the Carteira Digital de Transito (CDT) app, distributed by SENATRAN through the gov.br ecosystem. The eCNH carries the same CNH number and RENACH as the physical plastic โ the validation algorithm does not change. The digital card adds a QR Code that resolves to a SERPRO-signed JSON containing the CPF, CNH number, RENACH, category, expiration date and a cryptographic signature.
A pure-format validator like this one only inspects the 11 digits. It cannot tell you whether the card is digital or plastic, whether the holder is suspended, whether the document has been revoked (cassada) or whether the photo and biometrics actually match. Those checks require a Detran portal session or a paid SENATRAN bureau integration.
Use cases: delivery apps, KYC and mock data
Real-world places where an offline CNH number validator earns its keep:
- Delivery and ride-hailing onboarding: iFood, Uber, 99, Rappi and Loggi screens reject obviously malformed CNH numbers before reaching the SENATRAN proxy, which is rate limited and paid per request.
- Fleet management: telematics SaaS like Cobli, Frota Plus or Maxtrack maintain a driver master with CNH number + RENACH and reuse this validator on import.
- Insurance: motor policies require a valid CNH at quote time; a front-end validator avoids round-trips to the insurer back-office.
- Mock and seed data: QA environments need CNH numbers that pass the check digit test but are clearly fake. Combine this validator with a random generator.
- Fintech and bank account opening: PJ accounts for drivers (MEI) routinely store the CNH number as a secondary ID.
PPD vs PD, cassacao and what the validator cannot see
Brazil issues a PPD (Permissao Para Dirigir) on first approval โ a provisional licence valid for one year. After 12 months without serious infractions, the holder is upgraded to the PD (CNH definitiva). Both documents carry CNH numbers built with the same algorithm, so this tool validates them identically.
Cassacao (full revocation), suspensao (temporary suspension) and bloqueio (administrative block) are all recorded in the RENACH layer, never on the CNH number itself. A cassated driver still has a number that passes the algorithm โ only an online query against Detran or SENATRAN can reveal the status. This is the single most important caveat for any KYC team relying on offline validation.
FAQ
RENACH vs CNH number โ which one is on the card?
Both. The plastic shows the CNH number (field 4, "numero de registro") and the RENACH (field 5). The RENACH is the lifetime registry; the CNH number is tied to the specific document.
Does the CNH number change when I move to another state?
Historically yes โ the issuing Detran rewrote the number. With the unified national system the trend is to preserve the number when possible, but the RENACH is the field guaranteed to be stable for life.
Can I look up the CNH online?
Yes, through the state Detran portal (detran.<UF>.gov.br) or the CDT app on gov.br. Some Detrans require login with the CPF and a security question; SENATRAN does not expose a free public API.
Does this tool query BrasilAPI or any external service?
No. The check digits are computed locally in the browser. BrasilAPI does not currently expose a Detran proxy โ its CNH endpoint is unreliable because state Detrans block automated scraping.
Why do some CNH numbers start with 0?
Leading zeros are part of the number. The algorithm pads the base to 9 digits before computing weights, so 04881472561 is processed exactly like a number that begins with a non-zero digit.
Related Tools
CPF Validator
Validate Brazilian CPF numbers instantly using the official algorithm. Useful for testing document validation in applications. No data sent to servers.
Batch CPF Validator
Validate a list of CPFs (one per line) and see which are valid and which are not. No data sent to servers.
Batch CNPJ Validator
Validate a list of CNPJs (one per line) with a summary of valid, invalid and total. No data sent to servers.