CNPJ Generator

Generate valid CNPJ numbers for testing and software development. Generated CNPJs have mathematically correct check digits.

What is a CNPJ?

The CNPJ (Cadastro Nacional da Pessoa JurΓ­dica) is the unique registration number assigned by the Brazilian Federal Revenue Service to companies, associations, foundations and other legal entities. It works like a tax ID for businesses β€” it is the fiscal identity that allows legal operation in Brazil.

Every company that engages in economic activity in Brazil is required to have a CNPJ. It is necessary to open corporate bank accounts, issue invoices, participate in public bids, hire employees and perform various other commercial operations.

The CNPJ was created in 1998 to replace the CGC (General Taxpayer Registry) and is administered by the Special Secretariat of the Federal Revenue of Brazil, part of the Ministry of Economy.

CNPJ Structure

The traditional CNPJ consists of 14 numeric digits in the format XX.XXX.XXX/XXXX-XX. Each group of digits has a specific meaning:

The first 8 digits (root) identify the company. The next 4 digits (order) identify the headquarters (0001) or branches (0002, 0003, etc.). The last 2 digits are the check digits, calculated from the previous 12 using the modulo 11 algorithm.

For example, in CNPJ 11.222.333/0001-81, "11222333" is the company root, "0001" indicates it is the headquarters, and "81" are the check digits that confirm the number's validity.

How does the check digit calculation work?

CNPJ check digit calculation uses the modulo 11 algorithm. For the first digit, each of the first 12 numbers is multiplied by a specific weight from the sequence [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]. The sum of products is divided by 11 β€” if the remainder is less than 2, the digit is 0; otherwise, the digit is 11 minus the remainder.

The second digit is calculated similarly, but including the already calculated first check digit and using the weight sequence [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]. This double verification ensures that typing errors are easily detected.

This algorithm is the same one used by the Brazilian Federal Revenue to validate CNPJs and is widely implemented in software systems for registration data verification.

What is a CNPJ generator used for?

A CNPJ generator creates numbers with mathematically valid check digits, useful exclusively for testing and software development purposes. Generated CNPJs are NOT real registrations with the Federal Revenue and must not be used for any illegal or fraudulent purpose.

Developers use CNPJ generators to test form validations, simulate API integrations, populate test databases and verify that their systems correctly process the CNPJ format. It is an essential tool in the software development cycle.

Accountants and IT professionals also use CNPJ generators for educational purposes, such as demonstrating how the validation algorithm works in training courses.

Frequently Asked Questions

Is the generated CNPJ real?+
No. Generated CNPJs have valid check digits but do not correspond to real companies registered with the Federal Revenue. They are fictitious numbers for exclusive use in testing.
Can I use a generated CNPJ for legal purposes?+
No. Using a fictitious CNPJ for legal purposes such as opening accounts, issuing invoices or any type of fraud is a crime under Brazilian law. This tool is intended exclusively for development and software testing.
How to verify if a CNPJ is valid?+
You can use our CNPJ Validator to check if the check digits are correct. To verify if a CNPJ is active with the Federal Revenue, use our CNPJ Search tool.
How many CNPJs can I generate at once?+
You can generate up to 25 CNPJs at once using the quantity selector. All will have valid check digits and can be copied individually or all at once.
What is the difference between formatted and unformatted CNPJ?+
The formatted CNPJ displays dots, slash and hyphen (XX.XXX.XXX/XXXX-XX), making it easier to read. Unformatted, it is displayed as a 14-digit sequence, the format commonly used in API integrations.
Does the generator work with the new alphanumeric CNPJ?+
This generator creates CNPJs in the traditional (numeric) format. To generate CNPJs in the new alphanumeric format effective July 2026, use our Alphanumeric CNPJ Generator.