Brazil CNPJ check digits
Enter the base 112223330001 and get check digits 81, so the full CNPJ is 11222333000181; or paste 14 digits to confirm both trailing digits. Handy for invoices, supplier onboarding and data clean-up. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Number
- 112223330001
- Calculation mode
- Compute
- Input
- 112223330001
- Check digits
- 81
- Check digit 1
- 8
A Brazilian CNPJ (Cadastro Nacional da Pessoa Jurídica) ends with two check digits that prove the fourteen-digit company identifier was typed or stored without a transposition or single-digit slip. This capability implements the official Receita Federal mod-11 rule used on every CNPJ: twelve base digits identify the root registration and branch, then two trailing digits are derived with fixed weight sequences and a remainder-under-eleven rule. Use compute mode when you hold only the twelve-digit base and need both check digits for a form, invoice, or master-data import; use validate mode when a partner, ERP, or user submits a full fourteen-digit CNPJ and you need a clear valid flag plus the expected pair for error messages.
How Brazilian CNPJ check digits are calculated
A CNPJ is always fourteen digits when written without punctuation. The first eight digits form the root registration number assigned to the legal entity; the next four digits identify the branch (0001 is the usual headquarters branch); the final two digits are check digits and are never chosen freely.
To compute the first check digit, multiply the twelve base digits by the weight sequence 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2 from left to right, sum the products, take that sum modulo eleven, and map the remainder: if the remainder is less than two the check digit is zero, otherwise it is eleven minus the remainder.
To compute the second check digit, append the first check digit to the twelve-digit base and repeat the same mod-11 mapping with the thirteen weights 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2. The full fourteen-digit string must carry exactly those two trailing digits. The algorithm is deterministic and local: no Receita Federal network call, no catalog lookup, and no clock.
Compared with multi-country tax-ID validators, the search intent here is narrow: people who need a Brazil CNPJ check digits calculator for twelve-digit bases, not a general CPF-or-RFC checker.
Where CNPJ check digits fit real workflows
Finance and master-data teams receive twelve-digit internal company bases and must append the official CNPJ check digits before writing the identifier onto invoices, bank payment files, or marketplace seller profiles that reject invalid tax IDs. Accounts-payable portals validate fourteen-digit CNPJs at vendor onboarding so a single transposition does not create a phantom supplier and a payment mismatch. Data-quality jobs walk every CNPJ column in a CRM or ERP export, call validate mode, and quarantine rows where valid is false—catching both human edits and off-by-one bugs in generators.
Do not treat a passing CNPJ check as proof of active registration with Receita Federal or of a specific tax regime; it only proves the two mod-11 digits are consistent with the twelve-digit base under the standard weights.
What you can do with it
Audit CNPJ columns in ERP and CRM exports
Batch-validate every fourteen-digit CNPJ in a vendor or customer file and quarantine rows whose check pair no longer matches the recomputed expected value.
FAQ
What are Brazilian CNPJ check digits?
They are the last two digits of a fourteen-digit CNPJ, computed with two successive mod-11 weighted sums so typing and import errors are usually caught before the identifier is stored or printed on an invoice.
What happens with wrong length, letters, or punctuation?
All-identical bases are rejected in compute; all-identical full CNPJs return valid false in validate. Failed validation tasks are not billed.
Is the Brazil CNPJ check digits tool free?
The browser tool is free and runs locally.
What do the digit groups in a CNPJ mean?
The first eight digits are the root registration of the company, the next four identify the branch, with 0001 usually the headquarters, and the last two are check digits that are never chosen freely.
Does a valid CNPJ mean the company is active?
No. Passing the check only shows that the digits are consistent under the mod-11 rule. The tool makes no query to the Receita Federal, so it is not proof of an active registration.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/enc/cnpj-brazil \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"number":"112223330001"}'const res = await fetch("https://api.kit.forhosting.com/enc/cnpj-brazil", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"number": "112223330001"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/enc/cnpj-brazil",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"number": "112223330001"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/enc/cnpj-brazil", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"number":"112223330001"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"number":"112223330001"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/enc/cnpj-brazil", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"number": "112223330001"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "enc.cnpj_brazil",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Non-numeric input, wrong lengths, and all-identical digit strings fail with invalid_input or valid false instead of silent stripping, so you never store a half-cleaned tax ID. The same pure arithmetic runs free in the browser and at the published API price.
Input contract, modes, and error behaviour
Send a number field that contains only characters zero through nine. Wrong length is an explicit error that names the mode and the length you sent—twelve for compute, fourteen for validate—so client forms can show “need twelve digits” without guessing. Empty strings, missing number, invalid mode values, and all-identical twelve-digit bases in compute mode fail before any weighted sum is trusted for storage and are not billed. Prefer compute when you mint or complete company identifiers; prefer validate when you gate a lookup or import on a full CNPJ from a user or partner file. Spaces, dots, slashes, hyphens, letters, and decimal points are rejected as non-numeric input with invalid_input so a silently stripped value never reaches storage. Mode compute is the default: the engine requires exactly twelve digits, returns check_digits as a two-character string, returns check_digit_1 and check_digit_2 individually, and returns with_check as the fourteen-digit CNPJ you can print or persist. Mode validate requires exactly fourteen digits; the response reports valid true when both trailing digits match the recomputed expected_check_digits and the string is not an all-identical run such as fourteen zeros. Validate always includes payload (the first twelve digits), the given and expected check pairs, repeated_digits, and length fourteen. Alias keys such as digits, cnpj, and code are accepted for the same payload field so integrations that already speak “cnpj” do not need a rename. Because the path is pure parse with no clock, random source, or network, the same JSON body always yields the same JSON result on the free browser tool and on the API at $0.002 per successful request.
Where CNPJ check digits fit real workflows
E-commerce and B2B signup forms can recompute expected_check_digits and show a friendly correction when a Brazilian company pastes a number with a mistyped last pair.
Integration use cases
Complete a 12-digit CNPJ base for invoices
Call compute mode with the twelve-digit base, store with_check, and feed the fourteen-digit CNPJ into your NFe, bank remittance, or marketplace seller profile.
Validate typed or imported full CNPJs at entry
When a form or CSV submits fourteen digits, call validate mode and block save when valid is false, showing expected_check_digits to help correct a single mistype.
Technical questions
How do I compute CNPJ check digits with this API?
POST with number set to exactly twelve digits and mode compute (or omit mode). The response includes check_digits, check_digit_1, check_digit_2, and with_check (the full fourteen-digit CNPJ).
How do I validate a full fourteen-digit CNPJ?
POST with the fourteen-digit string and mode validate. The response includes valid, check_digits, expected_check_digits, payload (digits without the last pair), and repeated_digits.