- Home
- Skills
- APIs & Backend
- Brazil CPF & CNPJ Validator (alphanumeric CNPJ ready)
Brazil CPF & CNPJ Validator (alphanumeric CNPJ ready)
Correct CPF/CNPJ validation (alphanumeric CNPJ included), masks, test values and CEP lookup for Brazilian forms.
Free
Works with the AI Agents you already use
Brazil CPF & CNPJ Validator (alphanumeric CNPJ ready)
Example session with this skill installed
Valide estes documentos e diga quais são válidos: 12.ABC.345/01DE-35, 111.111.111-11, 529.982.247-25, 11.222.333/0001-82.
- Read your context and instructions
- Compiled the brazil cpf
Dos quatro documentos, dois são válidos. Conferi os dígitos verificadores à mão, sem rodar código.
| Documento | Tipo | Válido? | Motivo |
|---|---|---|---|
12.ABC.345/01DE-35 | CNPJ alfanumérico | Sim | O 1º DV calculado é 3 e o 2º é 5, os dois iguais aos informados. |
111.111.111-11 | CPF | Não | Todos os dígitos são iguais. Esse padrão é rejeitado, embora os DVs batam na conta. |
529.982.247-25 | CPF | Sim | O 1º DV calculado é 2 e o 2º é 5, os dois iguais aos informados. |
11.222.333/0001-82 | CNPJ | Não | O 1º DV (8) está correto, mas o 2º deveria ser 1, não 2. O CNPJ correto seria 11.222.333/0001-81. |
No CNPJ alfanumérico, cada letra vale seu código ASCII menos 48 (A=17, B=18 e assim por diante). Os pesos e o módulo 11 são os mesmos do CNPJ numérico.
Isso só confirma que a estrutura e os dígitos verificadores estão corretos. Não mostra se o documento está registrado ou ativo na Receita Federal.
Real output from a Claude Code session with this skill installed.
Connects securely to your tools. The creator never sees your data.
About this skill
Brazilian tax IDs are a recurring pain point for international and local developers alike, especially with the 2026 shift to alphanumeric CNPJs. Validators written for numeric-only CNPJs (a \d{14} regex, parsing each character as a digit) reject these new IDs, which means rejected registrations and broken checkouts. This skill provides the correct validation logic, formatting rules, and test data generation to handle modern Brazilian tax identifiers and address lookups.
What it does
- Validate IDs by implementing the specific mod-11 check digit algorithms for both CPF and CNPJ.
- Support Alphanumeric CNPJ by handling the new July 2026 standard where the first 12 positions include letters.
- Generate Test Data to produce random, checksum-valid tax IDs for test environments (they can coincide with real ones) for seeding databases or automated testing.
- Format Masks to correctly display IDs with standard Brazilian punctuation for UIs.
- CEP lookup guidance for the free ViaCEP API, including its not-found quirk (HTTP 200 with
erro).
How it works
- Validate existing IDs against the specific weight-based checksums and repeat-sequence filters.
- Generate fake but mathematically valid IDs using the
fakecommand for development environments. - Format raw strings into standard masked strings like
00.000.000/0000-00. - Look up addresses with ViaCEP following the documented rules (the script itself does not call it).
Frameworks & tools
This skill ships a standalone, standard-library Python script for validation, formatting and fake test values, plus instructions for ViaCEP address lookup. It is designed to be ported into any backend or frontend stack handling Brazilian user data.
Why this beats prompting it yourself
Most LLMs will hallucinate the old numeric-only CNPJ regex or fail to account for the specific ASCII-offset math required for the new 2026 alphanumeric standard. This skill ensures your validation logic is compliant with current Receita Federal specifications.
Use cases
- Add robust CPF/CNPJ validation to a sign-up form or checkout flow.
- Update legacy systems to accept the new alphanumeric CNPJ format.
- Generate valid seed data for staging environments without using real PII.
- Implement address auto-fill features using Brazilian postal codes.
Known limitations
Does not verify if an ID is active or exists in the official registry, only that it is well-formed. The ViaCEP API has no SLA and requires a manual entry fallback.
Validates check digits only; does not check active status in government registries. ViaCEP API lacks an SLA and requires manual fallbacks for rural or city-wide codes.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scan
Security scan passed 16 days ago
- Free with an Agensi account
Requires