CNH Generator
Generate mathematically valid Brazilian driver's license (CNH) numbers for testing. Follows the DETRAN algorithm. For test use only.
What is a CNH generator used for?
The CNH (National Driver's License) has 11 digits, with two check digits that DETRAN calculates. It works well for testing driver registration systems, car rentals and DENATRAN query APIs.
The numbers it produces are mathematically valid, yet fictitious. None of them is tied to a real person.
For testing and development use only.
How the Brazilian driver's licence number works
The CNH — Carteira Nacional de Habilitação — is the unified driver's licence issued by every state's Detran under rules set in the Código de Trânsito Brasileiro (Lei 9.503/1997). Two numbers appear on the card: a security/document number printed on the front that changes with each renewal, and the registro (registration number), an 11-digit identifier that stays with the driver for life. This generator emits the 11-digit registro and is the number the modulo-11 algorithm validates.
The registro is composed of nine identifying digits plus two check digits. The algorithm is a variant of modulo 11 with a special decremento rule that is unique to the CNH and trips up developers who try to reuse a generic CPF validator.
Check-digit algorithm
First DV. Multiply the nine identifying digits by the descending weights 9, 8, 7, 6, 5, 4, 3, 2, 1, sum the products, and take the remainder modulo 11. If the remainder is 10, set DV1 to 0 and remember a decremento of 2 — this offset will shift the second calculation. Otherwise DV1 equals the remainder and the decremento is 0.
Second DV. Multiply the same nine digits by the ascending weights 1, 2, 3, 4, 5, 6, 7, 8, 9, sum, modulo 11. Subtract the decremento (0 or 2). If the result is 10 or greater, DV2 becomes 0; if it is negative, add 11. The two-digit check pair is concatenated to the nine identifying digits to form the final 11-character registro.
Categories and what each one allows
- ACC (Autorização para Conduzir Ciclomotor) — mopeds up to 50 cc. Not a full CNH; it is the lightest credential.
- A — motorcycles, motor tricycles and any two/three-wheeled motor vehicle, regardless of displacement.
- B — cars and light vehicles weighing up to 3.500 kg with seating for up to 8 passengers besides the driver.
- C — trucks and cargo vehicles above 3.500 kg. Requires at least 1 year of B with no serious infractions.
- D — passenger transport with more than 8 seats (buses, minibuses). Requires 2 years of B or 1 year of C.
- E — combinations with a trailer over 6.000 kg, or articulated/towed vehicles. Requires 1 year of C or D.
- Combined categories AB, AC, AD, AE let the driver ride motorcycles and operate one of the heavier classes.
Validity, EAR and the CNH Digital
After Lei 14.071/2020, validity depends on the driver's age at renewal: 10 years if under 50, 5 years from 50 to 69 inclusive, and 3 years from 70 onward. Renewal requires a medical exam and, when applicable, a psychological one. The flag EAR (Exerce Atividade Remunerada) is printed on the card when the driver performs paid transport — taxi, ride-share, delivery, freight — and is mandatory for several categories. A new driver leaves the auto-school with a CNH Provisória, which becomes the CNH Definitiva after one year free of serious infractions. The CNH Digital, available through the official Carteira Digital de Trânsito app, has the same legal value as the plastic card and can be presented at roadside stops.
Points and penalties
Since 2021, the threshold that triggers suspension scales with the number of gravíssimas committed in the previous twelve months: 20 points with two or more gravíssimas, 30 points with one, and 40 points with none. Professional drivers (EAR) follow a separate ceiling of 40 points across all severities. After suspension the driver attends a refresher course; recidivism within twelve months may lead to cassação, the full revocation of the licence, after which the entire driver-formation process restarts.
Driver's licence number generator for testing
The CNH (Brazil's driver's licence) carries a number with its own check digits, and traffic, rental and insurance systems need valid ones to test with. This tool generates mathematically valid CNH numbers using the official algorithm.
They pass format validations, which helps seed development databases, approve a rental system or show off a driver registration without real data. And a quick reminder that this is fictitious data for software testing, never for fraud or forgery.
Since everything is generated in the browser, no external base comes into play. Produce as many CNH numbers as you need for your test environment.
Frequently asked questions
Can a generated CNH be used to drive or to validate a real transaction?
What is the difference between suspension and cassação?
Does a Brazilian CNH work abroad?
What changes between the registro and the security number?
Related Tools
Brazilian State Tax ID Generator
Generate valid Brazilian State Tax IDs (Inscrição Estadual) for SP, RJ, MG, RS, PR and BA. For fiscal software and SEFAZ integration testing.
Credit Card Number Generator
Generate valid credit card numbers using the Luhn algorithm for e-commerce and payment testing. Supports Visa, MasterCard and Elo. For test use only.
Brazilian Voter ID Generator
Generate mathematically valid Brazilian voter ID (Título de Eleitor) numbers for software testing. Follows the TSE official algorithm. For test use only.
CNH (BR Driver License) Card Generator (fake)
Generate fake Brazilian driver license card data — number, category, issue/expiry date, issuer. For mockups.
Brazilian Certificate Number Generator
Generate valid Brazilian birth, marriage or death certificate numbers for software testing. Standard 32-digit CNJ format. For test use only.
RENAVAM Generator
Generate mathematically valid Brazilian RENAVAM vehicle registration numbers for automotive software testing. Correct check digit. For test use only.