CPF & CNPJ Validator

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

  1. Paste or type a CPF or CNPJ — with or without dots, slashes and dashes.
  2. The tool detects the type and validates the check digits as you type.
  3. 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.

FAQ

How is a CPF or CNPJ validated?

Both use verification (check) digits. The tool recomputes them from the base digits and compares them with the ones you entered; it also rejects sequences of identical digits.

Does it send my data anywhere?

No. Validation happens entirely in your browser — nothing is uploaded.

Does a valid number mean it really exists?

No. It only means the number is mathematically well-formed; it does not check any official registry.

Can a CPF or CNPJ pass validation but still be invalid?

Yes. Check-digit validation only confirms the number is mathematically consistent. It does not verify that the number actually exists in the Receita Federal registry or belongs to a specific person or company. For that, you need an official API query.