What is a CPF generator?
The CPF (Cadastro de Pessoas Físicas) is the Brazilian individual taxpayer number. Almost every Brazilian form asks for it: bank accounts, online shops, payment gateways, invoices and government services. A CPF has 11 digits, and the last two are check digits calculated from the first nine.
A CPF generator produces numbers that are valid by that algorithm, so they pass the validation of a form or an API field. They are meant for testing software only: filling a sign-up form in a staging environment, seeding a database, writing unit tests for a validator or demoing a checkout without exposing a real person's data. A generated CPF is not registered with the Receita Federal (Brazil's tax authority), belongs to no one on purpose and will fail any lookup against official or credit bureau records. Using someone else's CPF, or a made-up one, to deceive a company or the government is a crime in Brazil.
The numbers are drawn on your device: nothing you generate or paste is sent to a server. The same page also validates CPFs you already have (see the CPF validator), and test documents covers ID numbers from other countries.
How to generate a test CPF
- Open the page: the country is already Brazil (BR) and the document CPF (individual tax ID).
- Under How many, pick 1, 5, 10 or 50. The list appears at once, with no repeated value inside the batch.
- Tick or untick With mask (dots, dashes, spaces). With the mask you get
529.982.247-25; without it,52998224725, the form most databases store. - Press Copy next to a number, or Copy all to take the whole batch, one per line, into a spreadsheet, a seed script or a test fixture.
- Need different numbers? Press Generate again. Quantity and mask are remembered for your next visit.
- To check a CPF you already have, paste it into the Validate box below, one per line.
Examples
Check digits of 529.982.247
The first nine digits are the base. For the first check digit, multiply each digit by a weight from 10 down to 2, add everything up and take the remainder of the division by 11. A remainder of 0 or 1 gives 0; otherwise the digit is 11 minus the remainder.
5×10 + 2×9 + 9×8 + 9×7 + 8×6 + 2×5 + 2×4 + 4×3 + 7×2 = 295
295 mod 11 = 9 → 11 − 9 = 2 (first check digit)The second check digit repeats the calculation over ten digits (the base plus the new 2) with weights from 11 down to 2:
5×11 + 2×10 + 9×9 + 9×8 + 8×7 + 2×6 + 2×5 + 4×4 + 7×3 + 2×2 = 347
347 mod 11 = 6 → 11 − 6 = 5 (second check digit)Result: 529.982.247-25.
Other bases
| Base (9 digits) | Full CPF |
|---|---|
| 123456789 | 123.456.789-09 |
| 987654321 | 987.654.321-00 |
| 111444777 | 111.444.777-35 |
| 000000001 | 000.000.001-91 |
A CPF can start with zero, so store it as a string, never as an integer.
Masked and unmasked
Masked: 529.982.247-25
Unmasked: 52998224725Both are the same CPF. A good form accepts either and normalises before saving.
Common errors and how to fix them
- "all digits are equal": values such as
111.111.111-11pass the check digit maths, but they are never issued and nearly every system rejects them. The generator never produces them. - "needs 11 digits": a digit got lost, usually the leading zero when a spreadsheet treated the column as a number. Format the column as text before pasting.
- "the check digit should be 25": the last two digits do not match the base, usually a typo or two swapped digits. The message shows what they should be.
- My form accepts it but the payment API rejects it: some services look the number up in official or credit records, and a test CPF will never be found there. Use the provider's sandbox and its documented test values.
- Duplicate key errors in my seed: one batch has no repeats, but two batches can overlap. Handle conflicts if the column is unique.
Frequently asked questions
Is a generated CPF a real person's number?
It is a random number that only satisfies the check digit rule. By chance it may match a number that was issued to someone, which is exactly why it must stay in test environments and never be used for a real registration.
Is it legal to use a CPF generator?
Generating numbers to test software is a normal development and QA practice. What is illegal is using a CPF that is not yours to pass as someone else, open accounts or get around a verification.
Will a generated CPF work on a Brazilian shopping or banking site?
No. Those services check the registration status with the Receita Federal, where a test number does not exist. It only passes format and check digit validation.
What does the ninth digit mean?
It identifies the tax region where the CPF was issued (8 for São Paulo, 7 for Rio de Janeiro and Espírito Santo, for example). This tool draws all nine digits at random, so the region is not chosen; validators do not care about it.
Is there a generator for Brazilian company numbers too?
Yes: the CNPJ generator creates company tax numbers, including the new alphanumeric format used since July 2026.
How to compute a CPF in code
JavaScript
One function computes both check digits; only the input length changes (9 or 10 digits).
function cpfDigit(digits) {
let sum = 0;
for (let i = 0; i < digits.length; i++) sum += Number(digits[i]) * (digits.length + 1 - i);
const rest = sum % 11;
return rest < 2 ? 0 : 11 - rest;
}
function isValidCpf(value) {
const s = value.replace(/\D/g, '');
if (s.length !== 11 || /^(\d)\1+$/.test(s)) return false;
return cpfDigit(s.slice(0, 9)) === Number(s[9]) && cpfDigit(s.slice(0, 10)) === Number(s[10]);
}
console.log(isValidCpf('529.982.247-25')); // truePython
import re
def cpf_digit(digits: str) -> int:
total = sum(int(d) * (len(digits) + 1 - i) for i, d in enumerate(digits))
rest = total % 11
return 0 if rest < 2 else 11 - rest
def is_valid_cpf(value: str) -> bool:
s = re.sub(r"\D", "", value)
if len(s) != 11 or len(set(s)) == 1:
return False
return cpf_digit(s[:9]) == int(s[9]) and cpf_digit(s[:10]) == int(s[10])
print(is_valid_cpf("529.982.247-25")) # TrueGo
func cpfDigit(digits string) int {
sum := 0
for i, c := range digits {
sum += int(c-'0') * (len(digits) + 1 - i)
}
if rest := sum % 11; rest >= 2 {
return 11 - rest
}
return 0
}
func isValidCPF(value string) bool {
s := regexp.MustCompile(`\D`).ReplaceAllString(value, "")
if len(s) != 11 || strings.Count(s, s[:1]) == 11 {
return false
}
return cpfDigit(s[:9]) == int(s[9]-'0') && cpfDigit(s[:10]) == int(s[10]-'0')
}Bash
Completing a nine-digit base in the terminal:
cpf_digit() {
local d=$1 n=${#1} sum=0 i
for ((i = 0; i < n; i++)); do sum=$((sum + ${d:i:1} * (n + 1 - i))); done
local r=$((sum % 11))
echo $((r < 2 ? 0 : 11 - r))
}
base=529982247
d1=$(cpf_digit "$base")
d2=$(cpf_digit "$base$d1")
echo "$base$d1$d2" # 52998224725