What Are CPF and CNPJ?
The CPF & CNPJ Validator instantly checks whether a Brazilian CPF (individual taxpayer) or CNPJ (company) number is mathematically valid. Both documents end in verification digits calculated from the preceding digits with a modulo-11 algorithm. This tool detects automatically whether you typed a CPF (11 digits) or a CNPJ (14 digits), recomputes the check digits, rejects well-known invalid sequences such as repeated digits, and tells you immediately whether the number is valid — formatting it for you. It is ideal for developers validating form input and for anyone double-checking a document, and it runs entirely in your browser so your data stays private.
CPF (Cadastro de Pessoas Físicas) is the Brazilian individual taxpayer registry number — an 11-digit code issued to every Brazilian citizen and resident by the Receita Federal. CNPJ (Cadastro Nacional da Pessoa Jurídica) is the equivalent for legal entities — a 14-digit code assigned to every company, non-profit and government body. Both numbers include check digits that can be mathematically verified, making it possible to detect typos or fabricated numbers instantly without querying any database.
How to Use the Validator
- Paste or type a CPF or CNPJ — with or without dots, slashes and dashes.
- The tool detects the type and validates the check digits as you type.
- Read the result: a green badge for valid numbers (with the formatted version) or a red badge for invalid ones.
Use Cases
- Validating CPF or CNPJ numbers entered in a form before submitting to a backend or API.
- Checking whether a document number copied from a receipt or contract is correctly formatted.
- Learning how the CPF/CNPJ check-digit algorithm works for development or compliance purposes.
- Quickly identifying whether a number is a CPF or CNPJ based on its length.
How the Check-Digit Validation Works
CPF validation multiplies each of the first 9 digits by a descending weight (10 down to 2), sums the products, computes remainder mod 11, and derives the first check digit. The process repeats with weights 11 to 2 for the second check digit. CNPJ uses weights 5,4,3,2,9,8,7,6,5,4,3,2 for the first check digit and 6,5,4,3,2,9,8,7,6,5,4,3,2 for the second.
Since 2026, CNPJ numbers can also contain letters in the first eight positions (alphanumeric CNPJ). This tool supports the new format: each character's value is computed as charCode − 48, then the same modular arithmetic applies.
Benefits and Use Cases
- Validate form input on the spot without using real personal data or a backend.
- Understand how the modulo-11 check digits work, useful for building your own validation.
- Runs 100% in your browser — the number you check is never uploaded anywhere.
Privacy
Validation runs entirely in your browser. The CPF or CNPJ you enter is never sent to our servers or to any external database. The tool only checks mathematical validity — it cannot tell you whether a number is registered.