Free Company Tax ID Generator — CNPJ, EIN, CIF, Partita IVA, USt-IdNr, SIREN/SIRET
Generate mathematically valid business tax identification numbers for Brazil (CNPJ), USA (EIN), Portugal (NIPC), Spain (CIF), Italy (Partita IVA), Germany (USt-IdNr), and France (SIREN/SIRET) — all in one tool. Every number passes the official check-digit algorithm of its country, making it ideal for software testing, QA workflows, form validation, and ERP integration.
This tool also supports the new Brazilian CNPJ alphanumeric format launching in July 2026 — the first generator online to offer both classic (numeric) and new (alphanumeric with A-Z) CNPJ generation side by side.
How to Use the CNPJ Generator
Generating a valid company tax ID takes three seconds:
- Select your country — Click the flag tab at the top. Each tab switches to that country's official algorithm, format, and validation rules. CNPJ (Brazil) is selected by default.
- Configure options — For Brazil, choose between Numeric (classic) or Alphanumeric (2026) format, and set whether to generate a Matrix (main establishment) or a Branch hierarchy (same root CNPJ, different order numbers). For other countries, toggle formatted output and set batch quantity.
- Click Generate — The result appears instantly with the full company data (Brazil) or the generated tax ID (other countries). For French SIREN, a complete SIREN + multiple SIRET hierarchy is generated in one click.
- Copy or export — Click the copy icon next to any number, press Shift+Enter to copy, or use the CSV/JSON export for batch results.
To validate an existing number, paste it into the Real-Time Validator input — the result appears immediately with the check-digit breakdown and country-specific decoded information.
CNPJ Generator Examples
| Country | Document | Example | Notes |
|---|---|---|---|
| 🇧🇷 Brazil | CNPJ (classic) | 45.892.112/0001-90 |
Matrix establishment |
| 🇧🇷 Brazil | CNPJ (new 2026) | AB.C34.5D6/0001-78 |
Alphanumeric root, valid mod 11 |
| 🇺🇸 USA | EIN | 45-1234567 |
Prefix 45 = Ogden campus (CA, UT, NV) |
| 🇵🇹 Portugal | NIPC | 501 234 567 |
First digit 5 = private company |
| 🇪🇸 Spain | CIF | B12345674 |
B = Sociedad de Responsabilidad Limitada |
| 🇮🇹 Italy | Partita IVA | IT12345678903 |
Luhn-like check digit |
| 🇩🇪 Germany | USt-IdNr | DE123456789 |
ISO 7064 Mod 11-10 |
| 🇫🇷 France | SIREN | 732 829 320 |
Luhn-valid, 9 digits |
Edge case — all-identical digits: 11.111.111/1111-11 is rejected by every correct CNPJ validator. Use it to verify your form's error handling on the invalid-input path.
Edge case — Branch hierarchy: Matrix 12.345.678/0001-90 and Branch 12.345.678/0002-73 share the same 8-digit root but have different order numbers and recalculated check digits.
What Is a CNPJ and How Does It Work
The Cadastro Nacional da Pessoa Jurídica (CNPJ) is the 14-character identifier for all companies and legal entities in Brazil, administered by the Receita Federal. It is required to issue invoices (NF-e), open business bank accounts, sign contracts, and conduct any fiscal operation.
The CNPJ has a precise internal structure: the first 8 characters identify the company root (shared by all establishments), characters 9–12 indicate the establishment order (0001 = matrix, 0002+ = branches), and the last 2 are check digits calculated by the Módulo 11 algorithm using the weights 5,4,3,2,9,8,7,6,5,4,3,2 (first check) and 6,5,4,3,2,9,8,7,6,5,4,3,2 (second check).
The new alphanumeric CNPJ (July 2026): Brazil is running out of numeric CNPJ space. Starting July 2026, the Receita Federal will issue CNPJs where the first 12 characters can include letters A–Z in addition to digits. Each letter has a numeric value (A=10, B=11, … Z=35) for the check-digit calculation. Existing numeric CNPJs remain valid — only new registrations will use the alphanumeric format.
Common Use Cases
- Form and API testing: Generate valid CNPJs to populate test databases, mock API responses, and validate front-end form logic without using real company data.
- ERP and billing system QA: Test matrix + branch hierarchies to verify that your system correctly processes multi-establishment companies — a scenario that requires CNPJs sharing the same root.
- Compliance and LGPD: Using real CNPJ data in development environments violates Brazil's LGPD. Generated CNPJs are mathematically valid but not registered with the Receita Federal — compliance by design.
- US EIN testing: Verify that your fintech or payroll system only accepts EINs with valid IRS-allocated prefixes — this generator uses only real IRS campus prefixes, not random 2-digit values.
- French SIREN/SIRET hierarchy: Test accounting software that models multi-establishment companies — generate one SIREN + N coherent SIRETs in one click, a scenario no other free tool provides.
- International e-commerce and ERP: Generate tax IDs for all 7 supported countries to test multi-region registration flows without relying on real business data.
Common Mistakes with CNPJ
- Using all-same-digit CNPJs as test data:
11.111.111/1111-11is invalid by definition of the algorithm. While useful to test error paths, never rely on it to test the happy path. - Confusing CNPJ and CPF: CPF (11 digits) identifies individuals; CNPJ (14 characters) identifies legal entities. Both use Módulo 11 but with different weights.
- Ignoring the branch structure in ERP tests: If you generate random CNPJs for a company with three branches, they will have different roots and won't be recognized as the same legal entity by fiscal systems. Use the Matrix + Branch generator to create a coherent hierarchy.
- Treating the new alphanumeric CNPJ as a breaking change: Existing numeric CNPJs remain valid indefinitely. The new format only applies to new registrations after July 2026. Test both formats if your system will handle post-2026 registrations.
Frequently Asked Questions
Does a generated CNPJ belong to a real company?
No. The generator creates numbers that satisfy the official Módulo 11 algorithm and pass any mathematical validation, but they are not registered with the Receita Federal. They are purely fictional and do not identify any real company. For looking up real companies, use the Receita Federal's public portal.
When does the CNPJ change to the alphanumeric format?
Starting July 2026, the Receita Federal will begin issuing CNPJs where the first 12 characters may include uppercase letters A–Z alongside digits. The check-digit algorithm remains Módulo 11, adapted so that each letter has a numeric value (A=10 through Z=35). CNPJs already issued in numeric format remain valid permanently.
How do you identify if a CNPJ is a matrix or branch?
The order digits (positions 9–12) tell you: 0001 = matrix (main establishment), 0002, 0003, etc. = branches. The first 8 digits (the root) are identical for the matrix and all its branches. This generator creates a coherent hierarchy when you select "Branch" mode — same root, sequential order numbers, and correctly recalculated check digits for each.
Why use IRS-valid prefixes for EIN generation?
The IRS allocates specific 2-digit prefixes to each processing campus. Prefixes like 00, 07, 08, 09, 17, 18, 19, 28, 29, 49 are not allocated and will fail validation in any system that checks prefix validity. This generator uses only real IRS-allocated prefixes, producing EINs that pass both format and prefix checks.
Does the validator check if a CNPJ is registered with the Receita Federal?
No. The validator checks mathematical validity only — whether the check digits are correct per the Módulo 11 algorithm. A mathematically valid CNPJ may or may not exist in the Receita Federal database. For checking real company registration status, use the Receita Federal's Comprovante de Inscrição portal.
How to Validate CNPJ in Code
The Módulo 11 algorithm below works for both the classic numeric format and the new alphanumeric format launching in July 2026. The only adaptation for alphanumeric: letters A–Z map to numeric values (A=10, B=11, … Z=35) before the weight multiplication. Everything else is identical.
Source: Receita Federal — CNPJ Structure Specification
JavaScript
function cnpjCharValue(c) {
if (c >= '0' && c <= '9') return parseInt(c);
return c.charCodeAt(0) - 65 + 10; // A=10 … Z=35
}
function validateCNPJ(input) {
const cnpj = input.replace(/[.\-\/]/g, '').toUpperCase();
if (cnpj.length !== 14) return false;
// Reject all-identical digit sequences (11111111111111 etc.)
if (/^\d+$/.test(cnpj) && new Set(cnpj).size === 1) return false;
const w1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
let sum = w1.reduce((acc, w, i) => acc + cnpjCharValue(cnpj[i]) * w, 0);
const d1 = sum % 11 < 2 ? 0 : 11 - (sum % 11);
const w2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
sum = w2.reduce((acc, w, i) => acc + cnpjCharValue(cnpj[i]) * w, 0);
const d2 = sum % 11 < 2 ? 0 : 11 - (sum % 11);
return cnpjCharValue(cnpj[12]) === d1 && cnpjCharValue(cnpj[13]) === d2;
}
console.log(validateCNPJ('45.892.112/0001-90')); // true
console.log(validateCNPJ('AB.C34.5D6/0001-78')); // true — alphanumeric 2026
console.log(validateCNPJ('11.111.111/1111-11')); // false
Python
import re
def cnpj_char_value(c: str) -> int:
return int(c) if c.isdigit() else ord(c.upper()) - 65 + 10 # A=10 … Z=35
def validate_cnpj(input_str: str) -> bool:
cnpj = re.sub(r'[.\-/]', '', input_str).upper()
if len(cnpj) != 14:
return False
if cnpj.isdigit() and len(set(cnpj)) == 1:
return False
w1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
total = sum(cnpj_char_value(cnpj[i]) * w1[i] for i in range(12))
d1 = 0 if total % 11 < 2 else 11 - (total % 11)
w2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
total = sum(cnpj_char_value(cnpj[i]) * w2[i] for i in range(13))
d2 = 0 if total % 11 < 2 else 11 - (total % 11)
return cnpj_char_value(cnpj[12]) == d1 and cnpj_char_value(cnpj[13]) == d2
print(validate_cnpj('45.892.112/0001-90')) # True
print(validate_cnpj('AB.C34.5D6/0001-78')) # True — alphanumeric 2026
print(validate_cnpj('11.111.111/1111-11')) # False
PHP
function cnpjCharValue(string $c): int {
return ctype_digit($c) ? (int) $c : ord(strtoupper($c)) - 65 + 10; // A=10 … Z=35
}
function validateCNPJ(string $input): bool {
$cnpj = strtoupper(preg_replace('/[.\-\/]/', '', $input));
if (strlen($cnpj) !== 14) return false;
if (ctype_digit($cnpj) && strlen(count_chars($cnpj, 3)) === 1) return false;
$w1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
$sum = 0;
for ($i = 0; $i < 12; $i++) $sum += cnpjCharValue($cnpj[$i]) * $w1[$i];
$d1 = ($sum % 11 < 2) ? 0 : 11 - ($sum % 11);
$w2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
$sum = 0;
for ($i = 0; $i < 13; $i++) $sum += cnpjCharValue($cnpj[$i]) * $w2[$i];
$d2 = ($sum % 11 < 2) ? 0 : 11 - ($sum % 11);
return cnpjCharValue($cnpj[12]) === $d1 && cnpjCharValue($cnpj[13]) === $d2;
}
var_dump(validateCNPJ('45.892.112/0001-90')); // bool(true)
var_dump(validateCNPJ('AB.C34.5D6/0001-78')); // bool(true) — alphanumeric 2026
var_dump(validateCNPJ('11.111.111/1111-11')); // bool(false)
Resources
- Receita Federal — CNPJ Structure — Official Brazilian tax authority, source of CNPJ rules and the upcoming alphanumeric format specification.
- IRS — Employer Identification Numbers — Official IRS page on EIN structure, allocation, and valid prefix ranges.
- INSEE — SIREN and SIRET — French national statistics institute defines SIREN and SIRET structure and the Luhn validation algorithm.
- SSN & CPF Generator — Generate and validate individual tax IDs: SSN (USA), CPF (Brazil), DNI (Spain), NIF (Portugal), Codice Fiscale (Italy), and NIR (France).