Brazil CPF & CNPJ Validator (alphanumeric CNPJ ready)

    1

    Correct CPF/CNPJ validation (alphanumeric CNPJ included), masks, test values and CEP lookup for Brazilian forms.

    Free

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    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.

    DocumentoTipoVálido?Motivo
    12.ABC.345/01DE-35CNPJ alfanuméricoSimO 1º DV calculado é 3 e o 2º é 5, os dois iguais aos informados.
    111.111.111-11CPFNãoTodos os dígitos são iguais. Esse padrão é rejeitado, embora os DVs batam na conta.
    529.982.247-25CPFSimO 1º DV calculado é 2 e o 2º é 5, os dois iguais aos informados.
    11.222.333/0001-82CNPJNãoO 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

    1. Validate existing IDs against the specific weight-based checksums and repeat-sequence filters.
    2. Generate fake but mathematically valid IDs using the fake command for development environments.
    3. Format raw strings into standard masked strings like 00.000.000/0000-00.
    4. 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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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

    Python 3.8+

    Permissions

    Terminal / Shell
    Listed16 days ago

    What's inside

    Frequently Asked Questions

    Yes. It implements the published rule: each character is worth its ASCII code minus 48 (A = 17 ... Z = 42), with the same weights and mod-11 as the numeric CNPJ. It validates the official Receita Federal example 12.ABC.345/01DE-35 and still accepts every numeric CNPJ.

    A SKILL.md with the CPF, CNPJ and CEP rules, storage and privacy advice, and scripts/ids.py, a standard-library Python script with validate, format and fake (cpf, cnpj, cnpj-alpha) commands. The skill is free.

    This skill performs algorithmic verification (mod-11 checksums) to ensure an ID is mathematically valid, but it does not query the government database to check if an ID is currently 'active' or assigned to a real person.

    While the core logic is provided via a Python-based implementation, the underlying algorithms and API structures are designed to be easily integrated into any AI agent or backend framework that handles user registration and data validation.

    Yes. The fake command generates random IDs that pass the checksum and are not taken from anyone. A random valid CPF or CNPJ can still coincide with a real one, so keep them in test environments and never send them to real registries, payment providers or e-mails.

    New in APIs & Backend