Numeric and Alphanumeric CNPJ Validator

Check whether a CNPJ passes the Receita Federal rule, whether it is the classic numeric one or the alphanumeric format issued since July 2026. When it fails, you see why.

One per line. Dots, slash, hyphen and spaces are ignored.

Result

Type or paste a CNPJ and click validate.

Need valid CNPJs to test with? Generate them in the numeric or alphanumeric format.

Generate CNPJ

Validating a CNPJ in a form or extracting it from a log?See the CNPJ regex

What this validator checks

The validator checks whether a CNPJ has the structure defined by the Receita Federal: 14 characters, only digits 0 to 9 and letters A to Z in the first 12, and two numeric check digits that match the calculation.

It detects on its own whether the number is numeric or alphanumeric, so it works for the CNPJ you already use and for the new format your application needs to accept.

When a CNPJ fails, the result says why: a character that cannot exist, wrong length, a check digit that is not a number or digits that do not match, with the expected value next to the informed one.

How the Receita Federal calculates the check digits

The calculation uses the first 12 characters and Modulo 11, and the alphanumeric CNPJ only changes how letters are converted.

Step by step:

  • Replace each character with its ASCII code minus 48. Digits stay as they are and letters go from A=17 to Z=42.
  • Multiply by the weights 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2 and add everything up.
  • Divide the sum by 11. If the remainder is 0 or 1, the first digit is 0. Otherwise it is 11 minus the remainder.
  • Append the first digit, use the weights 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2 and repeat the calculation to get the second.

In the official example, 12ABC34501DE gives the digits 35, forming 12.ABC.345/01DE-35.

When to use it

Situations where checking the digit right away saves you from hunting the bug in code:

Adapting your system to the new format

Test whether your registration form, API and database accept letters in the first 12 characters and reject what the Receita Federal rejects.

Checking test data

Paste the QA list of CNPJs, one per line, and see which ones have a wrong check digit before running the suite.

Debugging a rejection

Find out whether a CNPJ was refused because of length, a hidden character or the check digit.

Comparing with your own validation

Use the expected digit as a reference to confirm your function calculates the same as the Receita Federal manual.

Frequently Asked Questions about the CNPJ Validator

Answers for people who need to accept or test the alphanumeric CNPJ in their system.