joke2k / joke2k/faker

pt_BR: support new alphanumeric CNPJ format (Serpro, effective July 2026)

Open
#2,401 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
19.4k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

The pt_BR provider's `cnpj()` and `company_id()` still generate the old numeric-only CNPJ. Brazil's new alphanumeric CNPJ format is not supported. The first 12 characters can now be alphanumeric (`0-9`, `A-Z`); only the 2 check digits remain numeric.

### Steps to reproduce

1. `from faker import Faker`
1. `fake = Faker("pt_BR")`
1. `fake.cnpj()`

### Expected behavior

`cnpj()` should be able to produce alphanumeric CNPJs following the official Serpro algorithm, e.g. `12.ABC.345/01DE-35`. Check digits still computed via mod-11 over each character's value (`ASCII - 48`).

Reference: ["Cálculo dos dígitos verificadores de CNPJ alfanumérico"](https://www.gov.br/receitafederal/pt-br/centrais-de-conteudo/publicacoes/documentos-tecnicos/cnpj)

### Actual behavior

`cnpj()` only ever returns numeric values, e.g. `12.345.678/0001-95`. There is no way to generate the new alphanumeric format.

Contributor guide

Open the contributing guide

Research direction

Start at the pt_BR provider implementations of cnpj() and company_id(), then consult the linked Serpro reference for the alphanumeric calculation rules. Confirm how the existing formatted CNPJ is generated and test the resulting values against the stated character and check-digit requirements; done means both entry points can produce valid new-format CNPJs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
localization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.