CNPJ Generator & Validator - Brazilian Business ID Tool
Generate valid Brazilian CNPJ test numbers and check whether a CNPJ passes the official check-digit formula used by Brazil's Receita Federal tax authority.
Brazilian CNPJ Generator and Validator
CNPJ Generator
Generate a valid Brazilian CNPJ number for testing purposes.
CNPJ Validator
Check if a Brazilian CNPJ number is valid.
Documentation
What is a CNPJ?
CNPJ stands for Cadastro Nacional da Pessoa Jurídica. It is the identification number Brazil assigns to every registered business and other legal entity, similar to an EIN in the United States or a company registration number in the United Kingdom. A CNPJ is a 14-digit number, and the last two digits are check digits calculated from the first twelve. This tool generates numbers that pass that calculation, for use in software testing, and checks whether a given CNPJ number is mathematically valid.
The Brazilian Federal Revenue Service, known as Receita Federal, issues real CNPJ numbers and keeps the official registry. A number generated by this tool is not registered with Receita Federal and does not belong to any real company. It should be used only for testing, not for tax filings, contracts, or any official purpose.
CNPJ format
A CNPJ is written as XX.XXX.XXX/YYYY-ZZ. Each part means something:
- First 8 digits: the base number assigned to the company.
- Next 4 digits: the branch number.
0001is normally the company's head office, and0002,0003, and so on mark additional branches. All branches of one company share the same first 8 digits. - Last 2 digits: the check digits, calculated from the first 12 digits.
Example: 12.345.678/0001-95.
How to calculate CNPJ check digits
Both check digits use the same rule, called modulus 11: multiply each digit by a fixed weight, add the products, and turn the sum into a single digit.
First check digit (13th digit of the CNPJ):
- Multiply the first 12 digits by the weights
5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, in that order. - Add up the 12 products.
- Divide the total by 11 and keep the remainder.
- If the remainder is 0 or 1, the check digit is 0. Otherwise, the check digit is
11 − remainder.
Second check digit (14th digit of the CNPJ):
- Multiply the first 13 digits (the original 12 plus the first check digit just calculated) by the weights
6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2. - Add up the 13 products.
- Divide by 11 and keep the remainder.
- If the remainder is 0 or 1, the check digit is 0. Otherwise, the check digit is
11 − remainder.
A CNPJ where all 14 digits are the same, such as 11.111.111/1111-11, is always treated as invalid, since Brazilian rules do not allow that pattern regardless of what the formula produces.
Worked example
Take the base digits 1 2 3 4 5 6 7 8 0 0 0 1.
Step 1 — first check digit. Multiply each digit by its weight and add the results:
| Digit | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 0 | 0 | 0 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Weight | 5 | 4 | 3 | 2 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 |
| Product | 5 | 8 | 9 | 8 | 45 | 48 | 49 | 48 | 0 | 0 | 0 | 2 |
The products add up to 222. Dividing 222 by 11 gives a remainder of 2, so the first check digit is 11 − 2 = 9.
Step 2 — second check digit. The digit string is now 1 2 3 4 5 6 7 8 0 0 0 1 9 (13 digits, including the 9 from step 1). Multiplying by the second weight set and adding gives a total of 237. Dividing 237 by 11 gives a remainder of 6, so the second check digit is 11 − 6 = 5.
The full number is 12.345.678/0001-95, which is the example used throughout this page. Changing any single digit in the base number changes at least one check digit, which is why the formula catches most typing mistakes.
How to use this tool
Generator. Click "Generate CNPJ" to produce a new random number with correct check digits. Click "Copy" to copy it. Each result is independent; running the generator again produces a different number.
Validator. Type or paste a CNPJ into the input field, with or without punctuation, and click "Validate". The tool reports whether the number has 14 digits, is not a repeated-digit pattern, and has correct check digits.
What the validator does not check
The validator only confirms that a number is built correctly according to the check-digit formula. It cannot confirm that the number is registered with Receita Federal or that it belongs to an active company. Checking real registration status requires querying Receita Federal's own public lookup service or a licensed data provider. A number can be mathematically valid without being a real, registered CNPJ, and generated numbers from this tool fall into that category by design.
Frequently asked questions
What does CNPJ stand for? Cadastro Nacional da Pessoa Jurídica, Portuguese for National Registry of Legal Entities. It is Brazil's identification number for companies and other organizations.
How many digits does a CNPJ have? 14 digits: 8 for the company's base registration, 4 for the branch number, and 2 check digits.
Is a generated CNPJ safe to use? Only for testing software, filling sample databases, or learning the format. It is not registered with any authority and must not be used on tax forms, contracts, or real transactions.
Why is 11.111.111/1111-11 always invalid? Brazilian validation rules reject any CNPJ where all 14 digits are identical, as a fixed rule separate from the check-digit calculation.
What is the difference between validating and verifying a CNPJ? Validating checks the math: correct length, no banned repeated-digit pattern, and correct check digits. Verifying checks whether the number is actually registered to a real company, which requires looking it up in Receita Federal's database.
How is CNPJ different from CPF? CPF (Cadastro de Pessoas Físicas) identifies individuals and has 11 digits. CNPJ identifies businesses and other legal entities and has 14 digits. The two use different check-digit calculations.