# CPF & CNPJ Validator - Bulk Brazilian Tax ID Check (`kotablue-tools/cpf-cnpj-validator`) Actor

Validate up to 10,000 Brazilian CPF and CNPJ numbers offline: mod-11 check digits, formatting, alphanumeric CNPJ (RFB 2026), and a clear reason for every invalid value. No Receita Federal lookup, no API key.

- **URL**: https://apify.com/kotablue-tools/cpf-cnpj-validator.md
- **Developed by:** [KotaBlue Toolsmith](https://apify.com/kotablue-tools) (community)
- **Categories:** Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## CPF & CNPJ Validator: Bulk Brazilian Tax ID Check Digits (Offline)

**Paste a list of Brazilian CPF and CNPJ numbers in any common format and validate them all in one run. Each line gets one spreadsheet-ready row: VALID, INVALID or REPEAT, a plain-English reason, the document type, the value formatted and stripped, the check digits, and a flag for alphanumeric CNPJ.**

Up to 10,000 lines per run, checked offline with the public mod-11 verifier used for CPF and CNPJ: no API key, no login, no proxy, and your numbers are not sent to Receita Federal or any outside service. Built for cleaning CRM and KYC imports, rejecting typed-digit placeholders before a registry lookup, and supporting the alphanumeric CNPJ format (Receita Federal, from July 2026).

### What does this CPF / CNPJ validator do?

- **Checks CPF and CNPJ check digits.** Uses the standard mod-11 algorithm for CPF (Cadastro de Pessoas Físicas, 11 digits) and CNPJ (Cadastro Nacional da Pessoa Jurídica, 14 characters).
- **Supports alphanumeric CNPJ.** Accepts the new RFB format where the first 12 positions may contain letters A–Z (for example `12.ABC.345/01DE-35`), with numeric check digits, per Nota Técnica 49/2024.
- **Formats for display and storage.** Returns `295.379.955-93` / `54.550.752/0001-55` style formatting plus a punctuation-free stripped value ready for databases.
- **Reads messy input.** Dots, dashes, slashes, spaces, a leading `CPF:` / `CNPJ:` label and mixed case letters are handled.
- **Auto-detects the type.** 11 digits → CPF, 14 characters → CNPJ. Override with a per-line hint (`…, CPF`) or a run-wide Default type.
- **Rejects known placeholders.** Values like `111.111.111-11` or `00.000.000/0000-00` are flagged `ALL_SAME_DIGITS` instead of looking "valid".
- **Finds duplicates across formats.** `295.379.955-93` and `29537995593` are the same CPF; the second one comes back as `REPEAT`.
- **One clear status per line.** `VALID`, `INVALID` with a reason code, or `REPEAT`. Rows keep your input order.

### Who is this for?

- **KYC, KYB and onboarding teams.** Pre-validate Brazilian tax IDs before calling a paid registry or enrichment API, and drop obvious typos and placeholders.
- **Fintech, payments and banking ops.** Clean CPF/CNPJ columns in account-opening, PIX and merchant onboarding files.
- **CRM, ERP and data-quality teams.** Standardise tax-ID fields in Salesforce, HubSpot, ERP or spreadsheet exports and remove duplicates written with different punctuation.
- **E-commerce and marketplace sellers.** Check seller or buyer tax IDs collected at signup before pushing them into fiscal tooling.
- **Developers and automation builders.** Validate CPF/CNPJ fields in bulk from the Apify API, Make, Zapier or n8n with no Brazilian proxy and no Receita Federal scraping.
- **Compliance and audit support.** Produce a clear VALID/INVALID trail with reason codes for each input line (this is a data-quality check, not a registration proof).
- **Spreadsheet users.** Paste a column from Excel or Google Sheets and export the results back as CSV or Excel.
- **Teams preparing for alphanumeric CNPJ.** Start accepting letter-bearing CNPJs before July 2026 without changing your pipeline later.

### How to use it

1. Open the Actor and paste numbers into **CPF / CNPJ numbers to validate**, one per line. Punctuation is optional.
2. Leave **Default document type** on **Auto-detect by length**, or set CPF / CNPJ to force a type for the whole run.
3. For a single odd line, add a type hint after a comma, semicolon, `|` or tab, for example `29537995593, CPF`.
4. Click **Start**, then open the **Output** tab and filter on `status`, `reason` or `documentType`.
5. Export as CSV, Excel or JSON, or call the Actor from the Apify API, Make, Zapier or n8n.
6. Feed only the `VALID` rows into your Receita Federal / Serasa / enrichment step if you still need a live registry check.

### Input

| Field | Description |
|---|---|
| `documents` | One CPF or CNPJ per line, optionally followed by `, CPF` or `, CNPJ`. Max 10,000 lines per run. |
| `defaultType` | `AUTO` (default), `CPF` or `CNPJ`. Auto-detect uses cleaned length (11 = CPF, 14 = CNPJ). A per-line hint always wins. |

Example input (well-known library examples, one alphanumeric CNPJ, a blacklist CPF, a bad checksum, a short value, a repeat and a labelled CPF):

```json
{
  "documents": [
    "295.379.955-93",
    "54.550.752/0001-55",
    "12.ABC.345/01DE-35",
    "111.111.111-11",
    "295.379.955-94",
    "123",
    "295.379.955-93",
    "CPF: 390.533.447-05"
  ],
  "defaultType": "AUTO"
}
```

### Output

Each input line gives one dataset row. Fields:

`input, inputIndex, status, reason, firstStatus, message, documentType, documentFormatted, documentStripped, checkDigits, base, isAlphanumeric, typeSource, validatedAt`

Below are real rows from a local run on Nov 4, 2026 (America/Chicago) with the example input above. Empty fields and timestamps are left out; the same input is used for the cloud test.

A valid CPF:

```json
{
  "input": "295.379.955-93",
  "inputIndex": 1,
  "status": "VALID",
  "message": "Valid CPF check digits (mod-11). A valid checksum does not prove the CPF is registered with Receita Federal or that the holder exists.",
  "documentType": "CPF",
  "documentFormatted": "295.379.955-93",
  "documentStripped": "29537995593",
  "checkDigits": "93",
  "base": "295379955",
  "isAlphanumeric": false,
  "typeSource": "LENGTH"
}
```

A valid numeric CNPJ and a valid alphanumeric CNPJ:

```json
{
  "input": "54.550.752/0001-55",
  "inputIndex": 2,
  "status": "VALID",
  "documentType": "CNPJ",
  "documentFormatted": "54.550.752/0001-55",
  "documentStripped": "54550752000155",
  "checkDigits": "55",
  "isAlphanumeric": false
}
```

```json
{
  "input": "12.ABC.345/01DE-35",
  "inputIndex": 3,
  "status": "VALID",
  "message": "Valid CNPJ check digits (mod-11). This is the alphanumeric CNPJ format (Receita Federal, from July 2026). A valid checksum does not prove the CNPJ is registered with Receita Federal or that the company is active.",
  "documentType": "CNPJ",
  "documentFormatted": "12.ABC.345/01DE-35",
  "documentStripped": "12ABC34501DE35",
  "checkDigits": "35",
  "isAlphanumeric": true
}
```

An invalid blacklist CPF, a bad checksum, a short value and a repeat of the first CPF:

```json
{ "input": "111.111.111-11", "status": "INVALID", "reason": "ALL_SAME_DIGITS", "documentType": "CPF" }
```

```json
{ "input": "295.379.955-94", "status": "INVALID", "reason": "CHECKSUM_FAILED", "documentType": "CPF", "documentStripped": "29537995594" }
```

```json
{ "input": "123", "status": "INVALID", "reason": "WRONG_LENGTH" }
```

```json
{ "input": "295.379.955-93", "inputIndex": 7, "status": "REPEAT", "firstStatus": "VALID", "message": "Same CPF as input #1, which was VALID.", "documentType": "CPF" }
```

### Status and reason codes

| Status | Meaning |
|---|---|
| `VALID` | Check digits match for the detected or requested type. |
| `INVALID` | Failed a format or checksum rule; see `reason`. |
| `REPEAT` | Same type + stripped value as an earlier line in this run. |

| Reason | Meaning |
|---|---|
| `EMPTY` | Blank line. |
| `INPUT_TOO_LONG` | Line longer than 80 characters. |
| `UNKNOWN_TYPE_HINT` | Type hint was not CPF or CNPJ. |
| `BAD_CHARACTERS` | Characters left that the type does not allow. |
| `WRONG_LENGTH` | Not 11 (CPF) or 14 (CNPJ) after cleaning. |
| `TYPE_MISMATCH` | Forced type does not match the value length. |
| `ALL_SAME_DIGITS` | Rejected placeholder such as `111.111.111-11`. |
| `CHECKSUM_FAILED` | Mod-11 verifier digits do not match. |
| `AMBIGUOUS_TYPE` | Could not choose CPF vs CNPJ (rare; add a hint). |

### What a VALID result does and does not mean

A `VALID` row means **only** that the check digits are correct for that CPF or CNPJ string. It does **not** mean:

- the number is registered with Receita Federal;
- the person or company exists, is active, or matches a name you hold;
- the number is cleared for KYC, credit, tax filing or contracting.

Use this Actor to reject typos and placeholders cheaply, then call an official or licensed registry when you need proof of registration.

### Pricing

**Currently free** (not monetized). You only pay Apify platform usage for the run. A future per-result price may be added later; INVALID and REPEAT rows are intended to stay free if pricing is turned on.

### Limits and performance

- **10,000** documents per run (extra lines are skipped and counted in the run summary).
- **Offline only.** No Receita Federal, no Serasa, no network calls per row.
- **128 MB** default memory. A 10,000-document check finishes in well under a second of CPU time on a small heap; cloud runs typically peak far below 128 MB.
- Default run options: 300 s timeout, 128 MB. Raise memory only if you combine this Actor with heavy downstream steps in the same process.
- Rows are written in batches of 500 and keep your input order.

### FAQ

**Is this an official Receita Federal service?**\
No. It is an independent data-quality tool. It is not affiliated with, endorsed by or approved by Receita Federal do Brasil, the Brazilian Federal Revenue Service, or any Brazilian government body.

**Do you look up the CPF/CNPJ in a registry?**\
No. Everything is offline checksum and format validation. A valid checksum is not proof of registration.

**Does it support alphanumeric CNPJ?**\
Yes. The first 12 positions may be A–Z or digits; the two check digits stay numeric, following the RFB alphanumeric CNPJ rules.

**Can I mix CPF and CNPJ in one run?**\
Yes. With Default type `AUTO`, each line is classified by length. Use a per-line hint when you need to force a type.

**What about punctuated vs plain numbers?**\
Both work. `295.379.955-93` and `29537995593` validate the same way and share one REPEAT key.

**Why is `111.111.111-11` invalid?**\
Repeated-digit placeholders are on a reject list. They are commonly typed into forms and must not pass as valid IDs.

**Is my data sent anywhere?**\
No outside document API is called. Processing stays inside the Actor run on Apify.

**How is this different from a CNPJ scraper?**\
Scrapers call Receita Federal or third-party sites for company data and need proxies or keys. This Actor only checks format and check digits, so it is faster, cheaper and has no registry terms to navigate.

### Related tools

- [IBAN Validator](https://apify.com/kotablue-tools/iban-validator) — bulk IBAN & BIC/SWIFT check digits offline.
- [Phone Number Validator](https://apify.com/kotablue-tools/phone-number-validator) — bulk E.164 phone validation and formatting offline.
- [OFAC SDN Sanctions Screening](https://apify.com/kotablue-tools/ofac-sdn-sanctions-screening) — bulk name screening against the U.S. Treasury SDN list.
- [LEI Lookup & Renewal Checker](https://apify.com/kotablue-tools/gleif-lei-renewal-checker) — bulk LEI status and lapsed-LEI checks (GLEIF).
- [SEC EDGAR Company Lookup](https://apify.com/kotablue-tools/sec-edgar-company-lookup) — ticker/CIK to U.S. company filings.
- [ISIN / CUSIP / Ticker to FIGI + LEI Mapper](https://apify.com/kotablue-tools/figi-lei-identifier-mapper) — map security identifiers to FIGI and LEI.

### Libraries, attribution and disclaimer

- Check-digit logic is provided by **[@fnando/cpf](https://github.com/fnando/cpf)** and **[@fnando/cnpj](https://github.com/fnando/cnpj)** (MIT Licence, Copyright (c) 2018 Nando Vieira). The CNPJ library implements the alphanumeric algorithm documented by Receita Federal.
- CPF and CNPJ are Brazilian public identifiers. This Actor redistributes **no** Receita Federal registry data.
- **Not affiliated with, endorsed by or approved by** Receita Federal do Brasil, the Brazilian government, or the authors of the libraries above beyond the MIT licence terms.
- Results are a **data-quality aid only**, not legal, tax, KYC or credit advice. Always confirm registration through official or licensed channels when that proof is required.
- Keep the MIT copyright notice when you redistribute the libraries.

Built by [kotablue-tools](https://apify.com/kotablue-tools). Found a bug or want a field added? Open an issue on the Actor page.

# Actor input Schema

## `documents` (type: `array`):

One Brazilian tax ID per line: CPF (11 digits, for example 295.379.955-93) or CNPJ (14 characters, for example 54.550.752/0001-55 or alphanumeric 12.ABC.345/01DE-35). Punctuation is optional. Add a type hint after a comma, semicolon, | or tab when needed (for example 29537995593, CPF). A document repeated in the same run is returned as REPEAT. Max 10,000 lines per run.

## `defaultType` (type: `string`):

AUTO detects CPF (11 digits) vs CNPJ (14 characters) from the cleaned value. Set CPF or CNPJ to force a type for the whole run (a per-line hint still wins).

## Actor input object example

```json
{
  "documents": [
    "295.379.955-93",
    "54.550.752/0001-55",
    "12.ABC.345/01DE-35",
    "111.111.111-11"
  ],
  "defaultType": "AUTO"
}
```

# Actor output Schema

## `results` (type: `string`):

One row per input line with status (VALID, INVALID, REPEAT), reason, document type, formatted and stripped value, check digits and message.

## `summary` (type: `string`):

Counts per status, per invalid reason, CPF vs CNPJ and settings used.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "documents": [
        "295.379.955-93",
        "54.550.752/0001-55",
        "12.ABC.345/01DE-35",
        "111.111.111-11"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kotablue-tools/cpf-cnpj-validator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "documents": [
        "295.379.955-93",
        "54.550.752/0001-55",
        "12.ABC.345/01DE-35",
        "111.111.111-11",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("kotablue-tools/cpf-cnpj-validator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "documents": [
    "295.379.955-93",
    "54.550.752/0001-55",
    "12.ABC.345/01DE-35",
    "111.111.111-11"
  ]
}' |
apify call kotablue-tools/cpf-cnpj-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kotablue-tools/cpf-cnpj-validator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/VwQFYMNdmEWqo9XbB/builds/pcBoaQCqSugQIlgD7/openapi.json
