CPF/CNPJ Generator

Generate valid CPF and CNPJ numbers for testing and development. Validate existing documents.

For testing and development purposes only
Formatted output
120

CPF/CNPJ Generator

CPF (Cadastro de Pessoas Físicas) is the Brazilian individual taxpayer registry, an 11-digit number used to identify individuals for tax and financial purposes. CNPJ (Cadastro Nacional da Pessoa Jurídica) is the 14-digit registry for businesses. Both use modulo-11 check digit algorithms to ensure validity.

This tool generates valid CPF and CNPJ numbers with correct check digits for software testing and development. It also includes a validation mode to verify whether an existing CPF or CNPJ has valid check digits. All generation and validation is performed locally in your browser.

How it works

CPF check digits use weights 10-2 (first digit) and 11-2 (second digit) with mod 11. CNPJ uses weights 5,4,3,2,9,8,7,6,5,4,3,2 (first) and 6,5,4,3,2,9,8,7,6,5,4,3,2 (second) with mod 11. If remainder < 2, the check digit is 0; otherwise it is 11 - remainder.

Use cases

  • Testing form validation for Brazilian document fields
  • Populating test databases with valid document numbers
  • Verifying CPF/CNPJ check digit algorithms in your code
  • QA testing of payment and registration flows

Frequently asked questions

How does a valid CPF generator work?

The generator creates the first 9 digits randomly and then computes the two check digits using the official modulo-11 algorithm: the first check digit uses weights 10 down to 2, and the second uses weights 11 down to 2. If the remainder of the weighted sum is less than 2 the check digit is 0; otherwise it is 11 minus the remainder. The result is a number that passes any standard CPF validation routine.

Are generated CPF and CNPJ numbers real documents?

No. The numbers are only mathematically valid, meaning their check digits are computed correctly, but they are not registered with Receita Federal and do not belong to any person or company. They are intended exclusively for software testing and development. Using a generated number to impersonate someone or sign up for real services is fraud and illegal.

What is the difference between CPF and CNPJ?

CPF (Cadastro de Pessoas Físicas) is the 11-digit Brazilian taxpayer registry for individuals, while CNPJ (Cadastro Nacional da Pessoa Jurídica) is the 14-digit registry for companies and other legal entities. Both end in check digits calculated with modulo-11 algorithms, but they use different digit counts and weight sequences. Forms in Brazilian systems usually validate each type with its own routine.

How can I check if a CPF or CNPJ number is valid?

Use the tool's validation mode: paste the number and it recomputes the check digits locally in your browser. If the calculated digits match the last digits of the number, the document is structurally valid. Note that this only confirms the math — it cannot tell you whether the number is actually registered or active, since that information is only available from Receita Federal.

Why does my randomly typed CPF fail validation?

Because the last two digits of a CPF are not arbitrary — they are check digits derived from the first nine digits via the modulo-11 formula. A randomly typed sequence has only about a 1-in-100 chance of matching both check digits. Validators also commonly reject sequences with all identical digits, such as 111.111.111-11, even though they can satisfy the formula.

Related Calculators