CNPJ Generator
Generate valid CNPJ numbers with correct check digits using the mod-11 algorithm. Bulk generation up to 100 with formatting options.
About
A CNPJ (Cadastro Nacional da Pessoa JurΓdica) is a 14-digit identifier assigned by Brazil's Receita Federal to every registered legal entity. The first 8 digits form the company base registration, digits 9 through 12 encode the branch number (where 0001 denotes headquarters), and the final 2 digits are check digits computed via a weighted mod-11 algorithm. Using fabricated or structurally invalid CNPJs in development environments causes silent failures in fiscal APIs, payment gateways, and nota fiscal emission systems. This tool generates CNPJs that pass algorithmic validation but correspond to no real entity. They are intended exclusively for software testing, form validation, and database seeding.
The generator produces numbers that satisfy the exact verification procedure defined by InstruΓ§Γ£o Normativa RFB. Note: generated CNPJs are mathematically valid but fictitious. Using them in official documents or tax filings constitutes fraud under Brazilian law (Lei 8.137/90). For bulk test suites, the tool supports batch generation of up to 100 numbers per run with optional formatting masks.
Formulas
The CNPJ check digits are computed sequentially. First, the 12-digit base (registration + branch) is multiplied element-wise by a weight vector, summed, and reduced modulo 11.
The second check digit uses the same procedure over 13 digits (base + first check digit) with weight vector w2.
Where di is the i-th digit, w1 = [5,4,3,2,9,8,7,6,5,4,3,2], and w2 = [6,5,4,3,2,9,8,7,6,5,4,3,2]. The final CNPJ is the concatenation of base digits, branch digits, C1, and C2.
Reference Data
| Position | Digits | Description | Example |
|---|---|---|---|
| 1-8 | 8 | Company base registration number | 11222333 |
| 9-12 | 4 | Branch/establishment number (0001 = HQ) | 0001 |
| 13 | 1 | First check digit (mod-11 with weights 5 - 2,9 - 2) | 8 |
| 14 | 1 | Second check digit (mod-11 with weights 6 - 2,9 - 2) | 1 |
| Weight Sequences for Check Digit Calculation | |||
| 1st digit | 12 weights | 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2 | Applied to positions 1-12 |
| 2nd digit | 13 weights | 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2 | Applied to positions 1-13 |
| Mod-11 Remainder Rules | |||
| Remainder | < 2 | Check digit = 0 | remainder 0 or 1 β digit 0 |
| Remainder | β₯ 2 | Check digit = 11 β remainder | remainder 4 β digit 7 |
| Common Formatting Patterns | |||
| Formatted | 18 chars | XX.XXX.XXX/XXXX-XX | 11.222.333/0001-81 |
| Unformatted | 14 chars | XXXXXXXXXXXXXX | 11222333000181 |
| Known Invalid Sequences (Reject List) | |||
| 00000000000000 | All zeros | Passes mod-11 but rejected by Receita Federal | Must be excluded |
| 11111111111111 | All ones | Passes mod-11 but rejected by Receita Federal | Must be excluded |
| 22222222222222 | All twos | Same-digit sequences are invalid | Must be excluded |
| 33333333333333 β¦ 99999999999999 | All same | All repeated-digit CNPJs are excluded | Must be excluded |