Every system that handles people eventually needs fake people: a sign-up form filled in hundreds of times, a checkout that must accept a card number, a demo with a screen full of customers. Typing 1234 or 000.000.000-00 does not work, because any decent validation rejects it. Copying real records from production works too well, and that is the problem. The answer is synthetic data that is realistic enough to pass the same checks real data passes, and fictitious enough that it belongs to no one.
Why tests need realistic fake data
Placeholder values test almost nothing. A field that accepts "test" as a name never shows you that a long surname breaks the layout, that an accented character is mangled on its way to the database, or that the CPF mask fails when the user pastes the number without dots. Realistic data exercises the paths real users will take:
- Format validation: masks, lengths, separators and check digits, so the happy path is actually reachable.
- Edge cases: accented and compound names, 15-digit American Express numbers next to 16-digit cards, documents with leading zeros.
- Volume: seeding a database with thousands of plausible rows to test search, pagination and performance.
- Demos and screenshots: a screen full of believable data that exposes nobody's personal information.
What a check digit is for
A check digit is a digit computed from the others and appended to the number. Its purpose is modest: to catch typing mistakes before the number goes anywhere. Mistype a digit and the recomputed check digit no longer matches, so the form can complain without querying anything. It is not a security feature and it says nothing about whether the number was ever issued. Different identifiers use different schemes:
| Identifier | Scheme | What it catches |
|---|---|---|
| Payment card (ISO/IEC 7812) | Luhn, modulus 10 — one digit | Every single-digit error; most swaps of adjacent digits |
| Brazilian CPF | Modulus 11 — two digits | Single-digit errors and adjacent swaps |
| Brazilian CNPJ | Modulus 11, weights 2 to 9 — two digits | Single-digit errors and adjacent swaps |
| Spanish DNI | Modulus 23 — one control letter | Single-digit errors |
| EAN-13 barcode | Modulus 10, weights 1 and 3 — one digit | Every single-digit error |
Worked example: the Luhn check on a card number
Card numbers follow ISO/IEC 7812. The first digits identify the issuer — a leading 4 is Visa, 51 to 55 or 2221 to 2720 is Mastercard, 34 or 37 is American Express — the middle digits identify the account, and the last digit is a Luhn check digit, an algorithm patented by IBM engineer Hans Peter Luhn in 1960. Take the 15-digit payload 4000 1234 5678 901 and compute the 16th digit:
- 1 Starting from the rightmost digit of the payload and moving left, double every second digit, beginning with that rightmost one. The doubled digits are 1, 9, 7, 5, 3, 1, 0 and 4, which become 2, 18, 14, 10, 6, 2, 0 and 8.
- 2 If a doubled value is greater than 9, subtract 9 (the same as adding its two digits): 18 becomes 9, 14 becomes 5, 10 becomes 1. The doubled column now sums to 2 + 9 + 5 + 1 + 6 + 2 + 0 + 8 = 33.
- 3 Add the digits that were not doubled: 0 + 8 + 6 + 4 + 2 + 0 + 0 = 20. The total is 33 + 20 = 53.
- 4 The check digit is whatever brings the total to the next multiple of 10: (10 − 53 mod 10) mod 10 = 7. The full number is 4000 1234 5678 9017.
Validation runs the same procedure on all 16 digits, now doubling every second digit from the one before the check digit: the sum must end in 0, and here it is 60. Mistype the last digit as 8 and the sum becomes 61, so the form rejects it. Luhn catches every single-digit error and nearly every swap of two adjacent digits; the one swap it misses is 09 for 90.
Credit Card Generator Generate Luhn-valid test card numbers for Visa, Mastercard, American Express, Discover, Elo and Hipercard, with a random future expiry date. Open the toolWorked example: the two mod-11 digits of a CPF
The CPF is Brazil's individual taxpayer number, issued by the Receita Federal: nine base digits followed by two check digits, written 000.000.000-00. Both check digits use the same modulus 11 rule with descending weights. Take the base 123.456.789:
- 1 First check digit: multiply the nine digits by the weights 10 down to 2 — 1×10 + 2×9 + 3×8 + 4×7 + 5×6 + 6×5 + 7×4 + 8×3 + 9×2 = 210.
- 2 Divide by 11 and keep the remainder: 210 mod 11 = 1. If the remainder is 0 or 1, the digit is 0; otherwise it is 11 minus the remainder. Here it is 0.
- 3 Second check digit: append that 0 and repeat with ten digits and weights 11 down to 2 — 1×11 + 2×10 + 3×9 + 4×8 + 5×7 + 6×6 + 7×5 + 8×4 + 9×3 + 0×2 = 255.
- 4 255 mod 11 = 2, which is not 0 or 1, so the digit is 11 − 2 = 9. The complete number is 123.456.789-09.
Two details matter when you write a validator. Sequences of one repeated digit, such as 111.111.111-11, pass the arithmetic but are never issued, so validators reject them explicitly. And the ninth digit encodes the fiscal region of registration (8 is São Paulo, 9 covers Paraná and Santa Catarina). The CNPJ, the company registration number, works the same way with 12 base digits and weights cycling from 2 to 9; note that the Receita Federal has introduced an alphanumeric CNPJ format for new registrations from July 2026, which purely numeric validators will reject. Other countries use similar ideas: Spain's DNI takes the eight-digit number modulo 23 and maps the remainder to a letter, so 12345678 leaves remainder 14 and gets the letter Z.
CPF/CNPJ Generator Generate CPF and CNPJ numbers with correct check digits, with or without punctuation, or paste one to validate it. Open the toolValid is not the same as real
A CPF exists only if the Receita Federal has registered it to a person; confirming that requires a query to an authorised service, not arithmetic. A card is even further removed from its number. To be charged, a payment needs an account the issuer actually opened, the right expiry date, a security code (CVV or CVC) that the issuer derives with secret keys and that cannot be computed from the number, and then an online authorisation in which the issuer checks the balance, limits and fraud signals. A generated number fails at the first real step. That is exactly why it is safe to use in tests, and why it is useless for anything else.
Testing payments: use the provider's test cards
Luhn-valid numbers are right for testing your own form — masks, brand detection from the prefix, length rules, error messages — and wrong for testing a payment integration end to end, because a live gateway declines them. Stripe and Adyen, among others, publish official test card numbers that work only with test-mode credentials, including numbers that deliberately simulate a decline, insufficient funds or a 3-D Secure challenge. Use those, from the provider's current documentation, rather than generated or remembered numbers.
Why not just copy production data
Restoring a production backup into a staging environment is the quickest way to get realistic data, and one of the riskiest. Test environments tend to have weaker access controls, more people with access, verbose logs and third-party tools attached. Data protection laws such as the GDPR in the European Union and the LGPD in Brazil require personal data to be processed for a defined purpose, limited to what is necessary and protected by appropriate security measures; spreading customer records across test systems sits poorly with all three. A leak from staging is still a leak.
Synthetic data avoids the question. If you truly need production-like distributions, use properly anonymised data, never a raw copy.
Fake Name Generator Generate realistic names in English, Portuguese or Spanish, filtered by gender, to fill test records and demos. Open the toolWhat not to do with generated numbers
- Do not use a generated CPF, CNPJ or card number to sign up for a real service, claim a benefit, dodge an identity check or make a purchase. Presenting a fabricated identity or payment detail to deceive someone can amount to fraud or false identity under criminal law, whatever tool produced it.
- Do not assume a generated number is unused. A random CPF or card number with valid check digits may coincide with one that was really issued; keep generated values inside test systems and never send them to real third parties.
- Do not test live payment gateways with generated cards. Use the provider's sandbox and its published test numbers.