Tools

Documentation · Generators

Back to tool

Document Generator

Generate and validate Brazilian CPF and CNPJ in the browser — including the alphanumeric CNPJ format planned by Brazil’s tax authority from July 2026. Numbers are mathematically valid, but fictional.

Use only for tests, staging, and prototypes. Never use generated values as a real person or company document.

What the tool does

FeatureCPFCNPJ
Generateyesyes (alphanumeric or legacy numeric-only)
Validateyesyes (accepts both formats)
Format maskXXX.XXX.XXX-XXXX.XXX.XXX/XXXX-XX

Everything runs locally via the br-documents library.

No CPF/CNPJ is sent to a server. Generation and validation happen in your browser.

Alphanumeric CNPJ (2026 specification)

From July 2026, new CNPJs may mix letters and digits in the first 12 positions. The last 2 characters remain numeric check digits.

PartContent
First 120–9 and A–Z (uppercase)
Last 2digits 0–9 only (check digits)

Numeric-only (legacy) CNPJs remain valid. Both formats coexist.

Official example used in tests: 12.ABC.345/01DE-35.

Legacy mode in the tool

Enable the numeric-only option when you want generation or validation limited to classic digit-only CNPJs. Without it, the generator may produce alphanumeric CNPJs and the validator accepts both.

How check digits work

CPF and CNPJ share the same general idea: modulo 11 with fixed weights. Each character is multiplied by a weight, the products are summed, divided by 11, and the remainder becomes the digit (with a simple rule for small remainders).

Shared rule (modulo 11)

  1. Multiply each position by its weight.
  2. Sum the products.
  3. Take the remainder of division by 11 (sum % 11).
  4. If the remainder is 0 or 1, the digit is 0; otherwise it is 11 − remainder.

This runs twice (first and second check digit), including the first digit already computed on the second pass.

CPF (11 digits)

  • Body: 9 digits + 2 check digits.
  • 1st DV weights: 10, 9, 8, 7, 6, 5, 4, 3, 2
  • 2nd DV weights: 11, 10, 9, 8, 7, 6, 5, 4, 3, 2
  • All-identical digit sequences (e.g. 111.111.111-11) are rejected.

CNPJ (14 characters) — numeric and alphanumeric

  • Body: 12 characters + 2 check digits.
  • 1st DV weights: 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2
  • 2nd DV weights: 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2

In the alphanumeric format, each character becomes a number with:

value = ASCII code − 48

So '0''9' stay 0…9, and 'A''Z' become 17…42. The weights and modulo 11 are the same as numeric CNPJ — only the letter-to-number mapping changes before the sum.

All-identical character sequences are also rejected.

Technology used

  • br-documents library (CPF/CNPJ validate, generate, and mask — including 2026 alphanumeric mode).

Search tools

Search tools by name, description, or tag.