About
Use the CNPJ generator to create a valid CNPJ number.
What is CNPJ?
The Cadastro Nacional da Pessoa Jurídica (CNPJ), National Registry of Legal Entities, has functions similar to CPF but is unique to legal entities. It identifies companies at the Federal Revenue Service.
The CNPJ must be detailed on all invoices and receipts issued by the company and on product packaging. (wikipedia)
Generation and Validation of CNPJ
The CNPJ has 14 characters. The first 8 are the registration number (the root), the next 4 identify the branch (0001 for headquarters) and the last 2 are check digits calculated from the 12 before them. Until July 2026 all 14 were digits; the first 12 can now include letters too.
Alphanumeric CNPJ (from July 2026)
On 31 July 2026 the Receita Federal issued the first alphanumeric CNPJ: 00.000.000/E08G-12. A CNPJ can now have letters (A to Z) as well as digits in its first 12 characters, the 8-character root and the 4-character branch. The last 2 characters, the check digits, are still numbers.
CNPJs issued before remain valid and do not need to be replaced, so any system that reads or stores CNPJs now has to accept both formats. The format switch in the generator gives you test values in either one.
How the check digits are calculated
The rule comes from the Receita Federal's check-digit manual and covers both formats. Each character gets a value: its ASCII code minus 48. Digits keep their own value (0 to 9) and letters start at 17: A = 17, B = 18, C = 19, and so on up to Z = 42.
First check digit: give the 12 characters the weights 2 to 9 from right to left, starting again at 2 after the eighth character (5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2). Multiply each value by its weight, add the results and divide the sum by 11.
Worked through on 00.000.000/E08G-12, where E = 21 and G = 23:
0×5 + 0×4 + 0×3 + 0×2 + 0×9 + 0×8 + 0×7 + 0×6 + E(21)×5 + 0×4 + 8×3 + G(23)×2 = 175
175 mod 11 = 10
11 − 10 = 1Second check digit: add the first check digit to the end, which makes 13 characters, and repeat the same steps with the weights 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2.
0×6 + 0×5 + 0×4 + 0×3 + 0×2 + 0×9 + 0×8 + 0×7 + E(21)×6 + 0×5 + 8×4 + G(23)×3 + 1×2 = 229
229 mod 11 = 9
11 − 9 = 2For both digits, a remainder of 0 or 1 gives 0; any other remainder gives 11 minus the remainder. That gives 1 and 2, the last two digits of 00.000.000/E08G-12. In an all-digit CNPJ every value is the digit itself, so the old numbers pass exactly as before.
For developers
Store the CNPJ as text, never as a number, and convert it to uppercase before you validate it. Accept both formats, with or without the dots, slash and dash: 14 digits, or 12 characters from 0–9 and A–Z followed by 2 digits.
Every CNPJ this tool generates is synthetic test data. Passing the check only means the number is well formed: it is not a real company's record, and this site never looks up real records.
Using the tool
This tool was developed for programmers and testers who have the constant need to enter different CNPJ numbers in developing forms.