CNH Generator & Validator

Generate valid Brazilian driver's license (CNH) numbers for software testing and validate any CNH instantly.

For software testing only. The data generated here is random and does not belong to any real person or company. Using it for fraud or in bad faith is a crime.

How to use

  1. Click "Generate" to create a random CNH number whose two DENATRAN check digits are mathematically valid.
  2. To validate, paste any 11-digit CNH in the validation field: both check digits are recomputed as you type.
  3. Use "Copy" to grab the result. Everything runs in your browser — nothing is sent to any server.

About this tool

The CNH (Carteira Nacional de Habilitação) is the Brazilian driver's license. The number that identifies it — the registro — has 11 digits: nine that identify the document plus two check digits defined by DENATRAN and computed with two passes of modulo 11 arithmetic. This tool generates numbers that satisfy that math, and validates any number you paste against the same rule.

The second check digit has a quirk worth knowing if you are implementing the rule yourself. The first digit uses descending weights from 9 to 1; when its remainder reaches 10 the digit becomes 0 and a "discount" flag is raised. The second digit uses ascending weights from 1 to 9 and, when that flag is on, has 2 subtracted from it — wrapping back around 11 if the result goes negative — before the same 10-becomes-0 rule is applied. Implementations that skip the discount reject roughly one in eleven legitimate licenses, which is the usual reason two validators disagree about the same number.

Use it to populate test environments: driver registration forms, fleet management systems, ride-hailing onboarding and insurance quotes all ask for a CNH number, and any of them will reject a hand-typed sequence. The numbers here are random, drawn from your browser's cryptographic random source; they are not looked up in any Detran database and correspond to no real driver or license. Nothing is transmitted — generation and validation happen entirely on your device.

The formula

First check digit: multiply the 9 base digits by weights 9, 8, 7, 6, 5, 4, 3, 2, 1 and take the remainder of the division by 11; if it reaches 10 the digit is 0 and a discount of 2 is flagged. Second check digit: multiply the same 9 digits by weights 1, 2, 3, 4, 5, 6, 7, 8, 9, take the remainder of the division by 11, subtract the discount when it is flagged (adding 11 back if the result turns negative); if it reaches 10 the digit is 0.

Frequently asked questions

Is this a real document?

No. The number is random and only satisfies the DENATRAN check-digit math. It is not registered with any Detran and does not belong to any driver.

Which CNH number does this generate?

The 11-digit número de registro, the field almost every system validates. The espelho number, the security code and the PID printed on the card are separate fields with no public check-digit rule.

Why do two validators disagree about the same CNH?

Because many implementations skip the discount rule on the second check digit. When the first digit's remainder reaches 10, 2 must be subtracted from the second digit; validators that forget it wrongly reject about 9% of legitimate numbers.

How should a CNH number be formatted?

Officially as 11 plain digits with no punctuation. The optional formatting here adds a hyphen before the two check digits purely to make the number easier to read and proofread.

Can I use a generated CNH to rent a car or open an account?

No. Generated documents are for software testing only. Using them on real services may constitute fraud, which is a crime in Brazil.

Does the number leave my browser?

No. Generation and validation run 100% in JavaScript on your device. Nothing is uploaded, logged or stored.

Related tools

Long links? Shorten them for free

Vai.la turns any URL into a short link with click statistics, QR Code and your own biolink.

Vai.la is not responsible for how the tools are used or for decisions made based on their results.