skillfed

brazilnum

Validate Brazilian CNPJ, CEI, CPF, PIS/PASEP, CEP, and municipal numbers

brazilnum v0.10.0 337.6K downloads/30d#7,447 on PyPI99
Permissive license MIT Active released

What it is and what it does

Brazilnum is a validation and formatting library for Brazilian identification numbers used by individuals, businesses, and government systems. It handles CNPJ (corporate tax ID), CEI (business registration), CPF (individual tax ID), PIS/PASEP (social security), CEP (postal codes), and IBGE municipal codes. The library accepts both formatted strings and raw numeric input, auto-corrects missing leading zeros in integers, and treats missing values (None, NaN) as invalid rather than raising errors—useful for data pipelines with incomplete records.

Beyond validation, it provides formatting functions to display identifiers in standard Brazilian notation, parsing functions to extract components (firm ID, establishment number, check digits), and utilities to clean formatting. It recently added support for alphanumeric CNPJ format introduced in 2026. The package has no external dependencies and supports Python 3.9 through 3.14, making it lightweight for integration into larger systems.

Use it for:

  • Validate customer CNPJ or CPF during account registration or payment processing.
  • Parse CNPJ to extract firm and establishment identifiers for business lookup.
  • Format and clean Brazilian ID numbers from data imports or user input.
  • Validate CEP postal codes when processing Brazilian shipping addresses.
  • Batch-validate municipal codes from government or census data sources.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Validates and formats Brazilian identification numbers including CNPJ, CEI, CPF, PIS/PASEP, CEP, and municipal codes, with support for both numeric and alphanumeric formats.

Yes. The package is actively maintained, has zero known vulnerabilities, imposes no dependency overhead, and solves a specific domain problem well. Install it if you work with Brazilian identification numbers in production systems or data pipelines.

Install

brazilnum on PyPI

pip

pip install brazilnum

uv

uv add brazilnum

poetry

poetry add brazilnum

Installing brazilnum

Before you install

Low install friction with no runtime dependencies. Active maintenance: last release 21 days ago, repository shows ongoing development with 99 stars.

License in practice

MIT license permits commercial and private use with minimal restrictions; suitable for most projects.

Quickstart

pip install brazilnum

from brazilnum.cnpj import validate_cnpj
from brazilnum.cpf import validate_cpf

validate_cnpj('02.558.157/0001-62')  # True
validate_cpf('968.811.342-58')  # True

Requires Python 3.9 or newer.

Verify before relying

  • Whether alphanumeric CNPJ support (added in version 0.9.0) is production-ready or still experimental.
  • Performance characteristics when validating large batches of identifiers.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 21 days since the last release
Last repo commit
First released
Downloads 337,580/month — #7,447 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: brazilnum-0.10.0-py3-none-any.whl

Keywords: brazil, brasil, cnpj, cei, cpf, pis, pasep, cep

Development Status :: 4 - BetaIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Topic :: Utilities

Tags

brazilian identification validationcnpj cpf validationbrazil tax id checkerbrazilian postal code parservalidate brazilian numbers
brazil-specificdata-validation

More Utilities packages