skillfed

validate-docbr

Validate brazilian documents.

validate-docbr v2.0.0 255.7K downloads/30d#8,474 on PyPI484
Permissive license MIT Active released

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-docbr

uv

uv add validate-docbr

poetry

poetry add validate-docbr

Installing 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

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Typing :: Typed

Tags

brazilian document validationcpf cnpj validatorvalidate brazilian idbrazilian document generatorbrazilian registry documentsdocument mask formatterbrazilian identity verification
brazilian-documentsvalidationdata-generation

More Utilities packages