validate-docbr
Validate brazilian documents.
What it is and what it does
validate-docbr is a Python package for validating and generating Brazilian official documents. It provides a unified interface for eight document types: CPF (individual taxpayer ID), CNPJ (business registration), CNH (driver's license), CNS (health card), PIS (social security), electoral registration, RENAVAM (vehicle registration), and civil registry certificates. Each document type is implemented as a class with consistent methods for validation, batch validation, generation, and formatting.
The package is designed for use in Brazilian applications that need to verify user-supplied document numbers or generate test data. It has no external dependencies, making it lightweight to integrate. All document classes follow the same API: validate() checks a single document, validate_list() processes multiple documents, generate() creates new valid documents optionally with formatting masks, and mask() applies standard Brazilian formatting to a document string.
Use it for:
- Validate user-submitted CPF or CNPJ during account registration or payment processing.
- Generate realistic test data for Brazilian-focused applications during development and QA.
- Batch-validate document lists imported from external sources or databases.
- Format document numbers with standard Brazilian punctuation for display in user interfaces.
- Verify multiple different document types in a single operation using the package-level validate_docs function.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Validates and generates Brazilian identity and registration documents including CPF, CNPJ, CNH, CNS, PIS, electoral registration, RENAVAM, and birth/marriage/death certificates.
Yes. The package is actively maintained, has no dependencies, supports current Python versions, carries a permissive MIT license, and fills a clear need for Brazilian document validation in Portuguese-language applications. No known vulnerabilities. Install if you work with Brazilian identity or registration documents.
Install
validate-docbr on PyPI
pip
pip install validate-docbruv
uv add validate-docbrpoetry
poetry add validate-docbrInstalling validate-docbr
Before you install
Low install friction with no runtime dependencies. Actively maintained with recent releases and a stable repository; supports current Python versions.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions, making it suitable for commercial and open-source projects.
Quickstart
pip install validate-docbr
from validate_docbr import CPF
cpf = CPF()
print(cpf.validate("012.345.678-90")) # True
print(cpf.generate(mask=True))
Requires Python 3.10 or later.
Verify before relying
- Whether all document types support all four methods (validate, validate_list, generate, mask) equally.
- Performance characteristics when validating large lists of documents.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 132 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 255,664/month — #8,474 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: validate_docbr-2.0.0-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
brazilnumValidates and formats Brazilian identification…
permissive · top 15,000 on PyPI
clabeValidates and generates CLABE numbers, Mexico's…
permissive · top 15,000 on PyPI
BrazilFiscalReportConverts Brazilian electronic invoice XML files…
agpl · top 15,000 on PyPI
python-bcbStructured Python interface to fetch Brazilian…
unclear · top 15,000 on PyPI
spdx3-validateValidates SPDX 3 documents with context-aware…
permissive · top 15,000 on PyPI
workadaysCalculates working days, calendar days, and…
permissive · top 15,000 on PyPI
validate_emailValidates email addresses for proper format and…
copyleft · top 15,000 on PyPI
python-stdnumParses, validates, and reformats standard…
copyleft · top 5,000 on PyPI
spdx-toolsParse, validate, create, and convert SPDX…
permissive · top 5,000 on PyPI
tldsProvides a set of valid top-level domains…
permissive · top 15,000 on PyPI