CNH: what it is and how to test it
The CNH is the Brazilian national driver licence. Its registration number has 11 digits: 9 of sequence and 2 check digits. Forms that ask for the "número de registro" of the CNH validate these digits, so test data has to follow the rule.
For tests only. These numbers have a correct format and check digit but belong to no real person or account. Never use them to deceive, to open accounts or to bypass a check. The numbers on this page come from the same generator as the tool, with a fixed seed so that the examples do not change; the tool creates new ones at every click.
Structure of the number
11 digits without mask: 9 of sequence followed by 2 check digits. There is no official punctuation. Numbers of all equal digits are not accepted.
The check digit, step by step
The first check digit weights the 9 digits with 9, 8, 7, 6, 5, 4, 3, 2, 1, sums them and takes the remainder by 11; a remainder of 10 or more becomes 0 and a discount of 2 is kept. The second weights the same digits with 1 to 9, takes the remainder by 11, subtracts the discount, adds 11 if the result is negative, and a value of 10 or more becomes 0.
Worked example with 27372143040:
| Position | Value | Weight 1st digit | Weight 2nd digit |
|---|---|---|---|
| 1 | 2 | 9 | 1 |
| 2 | 7 | 8 | 2 |
| 3 | 3 | 7 | 3 |
| 4 | 7 | 6 | 4 |
| 5 | 2 | 5 | 5 |
| 6 | 1 | 4 | 6 |
| 7 | 4 | 3 | 7 |
| 8 | 3 | 2 | 8 |
| 9 | 0 | 1 | 9 |
First digit: sum with weights 9 to 1 = 169; 169 mod 11 = 4. Second digit: sum with weights 1 to 9 = 121; 121 mod 11 = 0. Check digits: 40.
Valid examples
Five numbers generated by the tool with a fixed seed, each one accepted by its validator:
| Without mask | Validator |
|---|---|
27372143040 | valid |
34773276410 | valid |
33597785289 | valid |
15436744415 | valid |
44352998218 | valid |
How the validator answers
The same first example, one with a changed ending and one truncated, checked by the validator:
| Value | Result | Reason |
|---|---|---|
27372143040 | valid | - |
27372143041 | invalid | the check digit should be 40 |
273721430 | invalid | needs 11 digits |
Common mistakes
- The CNH registration number is not the "espelho" number or the security number printed on the card: forms usually want the 11-digit registration number, and a validator will reject the others.
- The discount rule is the step that most home-made validators forget: when the first sum leaves a remainder of 10 or more, the second digit must be computed with a discount of 2.
Frequently asked questions
Does the CNH number show whether the licence is valid?
No. The check digits only confirm the format. Whether the licence is active, suspended or expired is a matter for Senatran and the state traffic department (Detran).
Why does a generated CNH sometimes end with a 00?
Because both check digits can be 0: the first when the remainder is 10 or more, the second when the discounted value is 10 or more. They are valid; a validator that rejects them has the discount rule wrong.
Can I use a CNH number generated here in a real system?
No. A number such as 27372143040 has a correct format and check, but nobody was issued it, and it may coincide with a real holder by chance. Use it in test environments, demos and automated tests that never leave your control.