CPF/CNPJ Generator

Generate CPF or CNPJ with valid check digits, masked or not, for test environments.

Overview

The CPF (Cadastro de Pessoa Física) has existed since 1965: Law 4,862 of November 29, 1965 established it as part of a Brazilian tax reform aimed at creating a single federal identifier for individual taxpayers. Before that, every agency and state maintained its own local registries with no unified numbering — the Federal Revenue simply had no way to cross-reference information about the same taxpayer across different parts of the country. Issuance and registry are handled by the Brazilian Federal Revenue (Receita Federal do Brasil), and the number follows a person for life: it does not change with marriage, divorce, or change of state. Unlike the Carteira de Identidade (RG) issued by each state, the CPF is federal and unique — which explains its presence in virtually every system that needs to identify an individual in Brazil.

The CNPJ has a parallel history. Its predecessor, the CGC (Cadastro Geral de Contribuintes), was created in 1986 to identify legal entities. The transition to the CNPJ name came with Law 9,715 of 1998. Both documents use the modulo 11 algorithm to compute check digits: each digit in the number receives a weight, the sum of the products is divided by 11, and the remainder determines the check digit. The process is applied twice, once for each verification digit. That is why sequences like 111.111.111-11, 222.222.222-22, and so on are explicitly invalid: legislation excluded them as obviously fictitious. A lesser-known detail: the ninth digit of a CPF indicates the original fiscal registration region — 1 for DF/GO/MT/MS/TO, 2 for AC/AM/AP/PA/RO/RR, and so on up to 9 for SP. This does not prevent using the CPF outside the region of origin, but does reveal where the person was originally registered.

One essential note for developers: both CPF and CNPJ can start with zero — 012.345.678-90 is a perfectly valid CPF. Storing or parsing them as int, float, or double often drops leading zeros or causes precision errors. Treat them as strings end to end. It is also worth remembering the difference between validation and verification: this tool validates mathematically — it confirms the number respects the check-digit algorithm — but does not verify with the Receita Federal whether the CPF or CNPJ is active, regularized, or actually belongs to a real person or company. For real verification, you need to access official Receita Federal services. The numbers generated here are intended exclusively for development and QA.

Technical deep dive

Common questions summarized

  • Do these numbers belong to real people?: Generation is random among valid check-digit combinations. Collisions are possible; use only in tests.
  • What is this tool for?: It runs fully in your browser: useful to validate, format, or convert data in everyday development.
  • Are my inputs sent to a server?: Processing happens locally with JavaScript. We do not store what you paste into the text areas.
  • Can I use this for real production data?: Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.

Sample payload to try

  • See also the larger "Code Snippets" sample; paste this excerpt to try locally: Typical use — Ambiente de homologação: preencher formulários com CPF/CNPJ sintaticamente válidos.

Tool guide

  • What CPF and CNPJ are Brazilian identifiers for individuals and companies, with check digits computed by official rules.

  • What the tool does Generates numbers that pass check-digit validation, with or without masking, for testing only.

  • Why use it Fill staging, QA, and demos without real documents. Do not use for fraud; collisions with real numbers are possible.

Code Snippets

Code example
Ambiente de homologação: preencher formulários com CPF/CNPJ sintaticamente válidos.

Typical use

Ambiente de homologação: preencher formulários com CPF/CNPJ sintaticamente válidos.

FAQ

Do these numbers belong to real people?

Generation is random among valid check-digit combinations. Collisions are possible; use only in tests.

What is this tool for?

It runs fully in your browser: useful to validate, format, or convert data in everyday development.

Are my inputs sent to a server?

Processing happens locally with JavaScript. We do not store what you paste into the text areas.

Can I use this for real production data?

Use at your own risk. For secrets (passwords, tokens), prefer controlled environments and your company policies. And always review the generated contents. Never trust blindly things you see on the internet.