Skip to main content
Skip to main content

CPF Generator

Generate valid CPF numbers with origin state and formatting. QA tests.

Waiting for generation...

About the CPF Generator by State

The Box4Dev CPF Generator is a free online tool designed to assist developers, testers (QAs), and students. It creates mathematically valid CPF (Cadastro de Pessoas Físicas) numbers, with the option to specify the state (UF) of origin. This is useful for testing systems that have business rules based on the document's tax region.

The main advantage is ensuring that system validation algorithms work correctly. All generated numbers, whether from a specific state or random, have check digits calculated according to official Federal Revenue rules.

Anatomy & Structure of Brazilian CPF

The Brazilian Individual Taxpayer Registry (CPF) consists of 11 decimal digits in 3 segments:

PositionFieldLengthMeaning & RuleExample
1 to 8Sequential Number8 digitsUnique citizen sequential base registration number12345678
9Fiscal Region1 digitFederal Revenue fiscal jurisdiction code (e.g. 8 for SP, 7 for RJ/ES, 6 for MG)8
10 & 11Check Digits2 digitsDual Modulo 11 check digits computed with weights 10..2 and 11..290

Official CPF Algorithm (Brazilian Federal Revenue Modulo 11)

CPF integrity is enforced through two sequential Modulo 11 check calculations:

CD1 = (Sum1 % 11 < 2 ? 0 : 11 - Rem1); CD2 = (Sum2 % 11 < 2 ? 0 : 11 - Rem2)
  1. 1. Multiply the first 9 digits by descending weights from 10 to 2.
  2. 2. Sum the products and take remainder modulo 11.
  3. 3. If remainder < 2, CD1 is 0; otherwise CD1 = 11 - remainder.
  4. 4. For CD2, multiply first 9 digits by weights 11 to 3 and CD1 by weight 2.
  5. 5. If remainder < 2, CD2 is 0; otherwise CD2 = 11 - remainder.
  6. 6. Sequence strings with 11 identical digits are rejected.

Frequently Asked Questions (FAQ)

Is the CPF generated by this tool valid?
Yes. The generated CPF is mathematically valid because it follows the official check digit calculation algorithm (modulus 11). This ensures it will pass any system validation, but it is important to remember that it is fictitious and does not correspond to a real person.
Can I use the generated CPF for registrations or purchases?
No. Using a generated CPF for purposes other than testing, study, or software development is discouraged and may be considered illegal. The tool was created to assist developers and QAs, not for fraudulent activities.
What does it mean to generate a CPF by state?
The ninth digit of the CPF indicates the tax region where the document was originally issued. By selecting a state in the 'Origin State' filter, our tool generates a CPF whose ninth digit corresponds to that specific region (e.g., SP = 8, RJ/ES = 7, RS = 0). This is useful for testing systems with logic based on the CPF's origin.
How does the CPF Generator work?
The tool generates the first eight digits of the CPF randomly. The ninth digit is defined randomly or based on the state you select. Finally, the last two digits (check digits) are calculated using the official algorithm. This results in a number that, although fictitious, is always mathematically valid.
Is it safe to use this tool?
Yes. Box4Dev does not store any of the generated data. All operations are performed in your own browser (client-side), ensuring total privacy and security.