CPF and CNPJ Validation API
At CPF.CNPJ, we simplify and streamline access to essential information about individuals and companies.
Why validating CPF and CNPJ goes beyond the check digit
Validating only the check digit of a CPF or CNPJ is not enough. The check digit (calculated with modulo 11) confirms only that the number sequence is formally valid — it does not guarantee that the document actually exists or that it is in good standing. It is possible to generate thousands of CPFs and CNPJs with correct check digits that were never issued by the Brazilian Federal Revenue.
As a result, fake records easily pass validations that check only the number structure. A form that accepts any CPF with a valid digit lets fraudsters create accounts in bulk, bypass per-customer limits and pollute the database with non-existent identities. For fraud prevention and anti-fraud, the only reliable approach is to verify the document’s real registration status at the official source.
Full validation combines two layers: formal validation (check digit, in milliseconds, with no query cost) and registration verification at the Federal Revenue (status Regular, Cancelled, Suspended, Void for CPF; Active, Closed, Unfit, Suspended for CNPJ). Only the sum of both layers guarantees that the document exists and is able to operate.
What the CPF and CNPJ Validation API delivers
1. Instant check-digit validation (modulo 11)
The API validates the structure of the CPF and CNPJ using the modulo 11 algorithm, the same standard defined by the Federal Revenue for calculating check digits. This formal check is instant and runs before any registration query, immediately discarding malformed numbers, repeated ones (such as 000.000.000-00) or typos.
2. Real registration-status verification at the Federal Revenue
Beyond the check digit, the API queries the document’s official registration status. For CPF, it returns whether it is Regular, Suspended, Cancelled, Pending Regularization or Void. For CNPJ, it returns the status (Active, Closed, Unfit, Suspended) along with the legal name, opening date and other registration data. This layer is what tells apart a document that is valid on paper from one that truly exists and is able to operate.
3. CPF and CNPJ support, including the 2026 alphanumeric CNPJ
The API validates both CPF and CNPJ through the same endpoint, automatically identifying the document type. Support includes the new alphanumeric CNPJ format, whose issuance is planned from 2026: the first eight characters of the root and the four order characters may contain letters and numbers, while the two check digits remain numeric, calculated with modulo 11 over the ASCII values of the characters.
4. Real-time REST/JSON response
Integration is done through a REST API that responds in JSON, ready to be called from any language or platform. Authentication is token-based, with no captcha and no need for a date of birth. The real-time response lets you validate documents directly in the signup, checkout or onboarding flow, without slowing down the user experience.
How to integrate the validation API
Integration is straightforward: authenticate with your token and send the CPF or CNPJ to the validation endpoint. The example below validates a CPF and a CNPJ via cURL and returns the registration status in JSON.
# Validate a CPF
curl -X POST "https://api.cpfcnpj.com.br/YOUR_TOKEN/2/json/cpf" \
-H "Content-Type: application/json" \
-d '{"cpf": "00000000000"}'
# Response (JSON)
# {
# "cpf": "000.000.000-00",
# "nome": "FULL NAME",
# "situacao": "REGULAR"
# }
# Validate a CNPJ (includes alphanumeric CNPJ)
curl -X POST "https://api.cpfcnpj.com.br/YOUR_TOKEN/9/json/cnpj" \
-H "Content-Type: application/json" \
-d '{"cnpj": "00000000000000"}'
# Response (JSON)
# {
# "cnpj": "00.000.000/0000-00",
# "razao_social": "EXAMPLE COMPANY LTDA",
# "situacao_cadastral": "ACTIVE",
# "data_abertura": "2015-01-01"
# }The full parameters, return codes and examples in other languages are in the official documentation at https://www.cpfcnpj.com.br/dev/. Sign-up is free and unlocks credits for immediate testing.
Why use the CPF and CNPJ Validation API
- Low latency (0.4-2s): Formal validation in milliseconds and registration query in seconds
- 99.9% uptime: Monitored infrastructure for continuous validation in production
- Formal + registration validation: Check digit (modulo 11) and real status at the Federal Revenue
- CPF and CNPJ coverage: Same endpoint for CPF and CNPJ, including the 2026 alphanumeric CNPJ
