Brazil CPF validator (mod-11)
The CPF (Cadastro de Pessoas Físicas) is Brazil’s individual taxpayer number, required for nearly every formal transaction — opening a bank account, signing a contract, or filing taxes. Its last two digits are a checksum, so a single typo usually makes the whole number invalid. This validator recomputes those check digits and tells you instantly whether a CPF is well-formed, which is useful for developers, form validation, and back-office checks.
How it works
A CPF is 11 digits: 9 base digits + 2 check digits. Each check digit is a weighted mod-11 sum:
- First check digit — weight the 9 base digits by 10, 9, 8 … 2, sum them, take
sum mod 11. The digit is0if the remainder is below 2, otherwise11 − remainder. - Second check digit — repeat over the 9 base digits plus the first check digit, weighted 11, 10 … 2.
The CPF is valid only when both recomputed digits match what was entered. Reserved all-identical sequences (like 111.111.111-11) are rejected outright.
Example
Validate 529.982.247-25:
- Base digits:
529982247. - First check digit weighting (10…2) gives a remainder that maps to 2.
- Second check digit weighting (11…2) over
5299822472maps to 5. - Entered check digits
25match → valid CPF.
Check-digit rule
| Remainder (sum mod 11) | Check digit |
|---|---|
| 0 or 1 | 0 |
| 2 | 9 |
| 3 | 8 |
| … | 11 − remainder |
| 10 | 1 |
Privacy: the mod-11 calculation runs entirely in your browser. Your CPF is never uploaded or stored, and a valid result confirms internal consistency, not that the number is registered with Receita Federal.