1001Ferramentas
🚘 Generators

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 CNHCarteira 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.

FAQ

Can a generated CNH be used to drive or to validate a real transaction? No. The 11-digit number satisfies the algorithm but is not registered in RENACH, the federal database. Using it to misrepresent yourself in a stop, fine, insurance claim or ride-share platform is fraud (Código Penal arts. 297-299) and also a traffic offence (CTB art. 162). Legitimate uses are testing form validators, mock data and integration tests against Detran sandbox APIs.

What is the difference between suspension and cassação? Suspension is temporary — the licence is held for a defined period (months to two years) and returns after a refresher course. Cassação is full revocation: the driver is barred from driving for two years and must redo the entire formation, including the theoretical and practical exams, to obtain a new CNH.

Does a Brazilian CNH work abroad? Only in countries that recognise it directly (most Mercosur partners). For longer stays or other jurisdictions, request a Permissão Internacional para Dirigir (PID) at any Detran — it is a translated booklet valid for one year that accompanies the original CNH.

What changes between the registro and the security number? The registro is the lifetime identifier validated by this tool. The security number (also called número do espelho) changes at every renewal or second-copy issuance and is used to bind the printed document to the current photo and signature.

Related Tools

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.