Brazilian National Registry of Legal Entities

CNPJ

Cadastro Nacional da Pessoa Jurídica. Brazilian business taxpayer identification number.

Reference Boundary Browser-checkable specification

Use this page for field meaning, local checksum math, examples, and integration notes. Official identity, registry, account, or tax status still belongs to the owning system.

Local spec Draft specification Reviewed 2026-07-12
Quick Facts

Entity Summary

Jurisdiction
Brazil (BR)
Category
Brazilian National Registry of Legal Entities
Format
14 numeric digits
Local signal
Company root, branch, two check digits
Overview

What is CNPJ?

CNPJ (Cadastro Nacional da Pessoa Jurídica)

The CNPJ (Portuguese: Cadastro Nacional da Pessoa Jurídica, National Registry of Legal Entities) is the tax registration number used to identify businesses, partnerships, and non-profits in Brazil.

It is issued and administered by the Secretariat of the Federal Revenue of Brazil (Receita Federal).

Issuing Authority

Managed by the Secretariat of the Federal Revenue of Brazil (Secretaria da Receita Federal do Brasil).

Visualization

Visual Structure Breakdown

registration
RRRRRRRR
branch
BBBB
checksum
CC

Standard CNPJ numbers consist of exactly 14 digits structured as:

[ R R R R R R R R ] [ B B B B ] [ C C ]
FieldPositionsDescription
RRRRRRRR1–8Business registration number.
BBBB9–12Branch identifier (headquarters is usually 0001).
CC13–14Double control checksum digits.
Verification Math

Modulo Checksum Details

The CNPJ checksum utilizes a sequential double modulo 11 calculation.

First Checksum Digit (Digit 13)

Weights are applied to digits 1-12: 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2.

\[S_1 = \sum_{i=1}^{12} (d_i \times w_i)\]

\[R_1 = S_1 \pmod{11}\]

The control digit is computed as:

  • If \(R_1 < 2\), then \(d_{13} = 0\)
  • If \(R_1 \ge 2\), then \(d_{13} = 11 - R_1\)

Second Checksum Digit (Digit 14)

Weights are applied to digits 1-13: 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2.

\[S_2 = \sum_{i=1}^{13} (d_i \times w'_i)\]

\[R_2 = S_2 \pmod{11}\]

The control digit is computed as:

  • If \(R_2 < 2\), then \(d_{14} = 0\)
  • If \(R_2 \ge 2\), then \(d_{14} = 11 - R_2\)
Test cases

Validation Examples

Sample Input Description Status
11222333000181 Valid CNPJ — Standard valid Brazilian Cadastro Nacional da Pessoa Jurídica (CNPJ) number. ✓ Valid
11111111111111 Trivial Sequential Code — Fails the Receita Federal rule blocking identical repeating digits. ✗ Invalid
12345 Too Short — Must be exactly 14 numeric digits. ✗ Invalid
Developers

Implementation Guidance

Developer Guidelines

When implementing CNPJ validation:

  • CNPJ is formatted as: 00.000.000/0001-00. Separators must be filtered before calculation.
  • Digits length must be exactly 14.
  • Regex: /^\d{14}$/.
  • Like CPF, reject trivial sequential values (e.g. 00.000.000/0000-00, 11.111.111/1111-11), which are invalid.
API Language Code Snippets
function validateCNPJ(cnpj) {
  if (!/^\d{14}$/.test(cnpj)) return false;
  if (/^(\d)\1{13}$/.test(cnpj)) return false;
  let size = cnpj.length - 2;
  let numbers = cnpj.substring(0, size);
  const digits = cnpj.substring(size);
  let sum = 0;
  let pos = size - 7;
  for (let i = size; i >= 1; i--) {
    sum += parseInt(numbers.charAt(size - i)) * pos--;
    if (pos < 2) pos = 9;
  }
  let result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
  if (result !== parseInt(digits.charAt(0))) return false;
  size = size + 1;
  numbers = cnpj.substring(0, size);
  sum = 0;
  pos = size - 7;
  for (let i = size; i >= 1; i--) {
    sum += parseInt(numbers.charAt(size - i)) * pos--;
    if (pos < 2) pos = 9;
  }
  result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
  return result === parseInt(digits.charAt(1));
}
FAQ

Frequently Asked Questions

Can a company have multiple CNPJ numbers?

A business receives one base 8-digit registration number, but each branch or subsidiary receives its own 14-digit CNPJ code (e.g. branch 2 will end in /0002-XX).

Is CNPJ registration public?

Yes. Registration details, active statuses, and company locations are public domain databases provided by the Receita Federal.

References

Official Registry Sources

References

1. Receita Federal (Brazil): Central business registry lookup portal. Official portal.

2. RFB Normative Instruction No. 1863/2018: Administrative base of CNPJ registration rules.