This tool checks whether a CNPJ — Brazil's company tax ID — is valid, and tells you precisely why when it is not. It accepts both the classic all-numeric format and the new alphanumeric one arriving in July 2026, with or without the XX.XXX.XXX/XXXX-XX mask. A valid ID is confirmed as numeric or alphanumeric; an invalid one is explained — wrong length, a forbidden character, non-numeric check digits, or check digits that simply do not match. When only the check digit is wrong, it shows you the CNPJ it should have been.
What “valid” actually checks
A CNPJ is fourteen positions: a twelve-position base (an eight-position root plus a four-position branch identifier) followed by two check digits. Validation is structural, not a lookup against Receita Federal's database — it confirms the number is internally consistent. Four things have to hold: the length is exactly fourteen after the mask is stripped; the base characters are drawn from the allowed alphabet; the last two positions are numeric; and those two digits equal what the módulo 11 algorithm computes from the first twelve. A genuine CNPJ passes all four. A typo, a transcription slip, or a made-up number fails at least one — and a good validator names which.
The check digit, briefly
The verification rests on the same módulo 11 scheme the numeric CNPJ has always used, with one addition for letters. Each base character becomes a number by the rule value = ASCII − 48, so 0–9 map to 0–9 and A–Z map to 17–42. The first check digit is a weighted sum of the twelve values with weights 5 4 3 2 9 8 7 6 5 4 3 2 taken modulo 11 (remainder 0 or 1 → digit 0, otherwise 11 − remainder); the second repeats over the twelve values plus the first digit with weights 6 5 4 3 2 9 8 7 6 5 4 3 2. The official sample 12.ABC.345/01DE-35 validates exactly this way. If you want the full worked arithmetic on a number of your own, the check-digit calculator lays out every term.
Why numeric-only validators start failing in 2026
This is the part that matters for anyone shipping software. From July 2026 new registrations can carry letters in the first twelve positions, so a validator built around ^\d{14}$ will reject a perfectly valid alphanumeric CNPJ the moment a new partner, supplier, or customer presents one. The failure is silent and downstream: a blocked signup, a rejected invoice, a payment that will not go through — all because a regular expression has not been widened. Existing numeric CNPJs are untouched and stay valid forever, so the risk is entirely about accepting the new format, not re-checking the old one. Testing your validation against real alphanumeric samples now is the cheap insurance.
Why this validator accepts I and O
A recurring question is whether every letter is allowed. For validation, yes: the full A-Z range is accepted, and a CNPJ containing I or O that satisfies módulo 11 is structurally valid — this tool confirms it rather than rejecting it. Separately, the technical group ENCAT recommended in Nota Técnica Conjunta 2025.001 that Receita avoid issuing the visually ambiguous letters I O U Q F. At the time of writing that is a recommendation pending confirmation, not a validation rule. The distinction is practical: a validator must accept those letters (an issued ID could legitimately contain them), while a generator of test data does well to avoid them by default.
Updating your own validation
Three changes cover most systems. Widen the database column that stores a CNPJ from a numeric type to text. Replace any ^\d{14}$ pattern with ^[A-Z0-9]{12}[0-9]{2}$. And make the check-digit routine convert characters with ASCII − 48 instead of parsing integers — the weights and the remainder rule are unchanged, so you extend one algorithm rather than maintaining two. Because digits keep their own value under ASCII − 48, the updated routine returns the identical result for every numeric CNPJ you already store. Serpro publishes reference implementations of the routine in Java, Python, and TypeScript, which make a useful conformance oracle when you port the logic into your own stack. For more on the rollout and what it means for your stack, see our guide on what changes with the alphanumeric CNPJ. Everything here runs entirely in your browser — nothing you paste is sent anywhere.

