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)