# Phone Number Validator & Formatter (Bulk, CSV, Dataset) (`ocrad/phone-number-validator-formatter`) Actor

Validate and format phone numbers in bulk from a list, free text, CSV, Excel, Google Sheets or any Apify dataset. Get valid/invalid, line type, E.164 and national formats, country, city, time zone and risk flags, with duplicates removed. No API key needed.

- **URL**: https://apify.com/ocrad/phone-number-validator-formatter.md
- **Developed by:** [Ocrad](https://apify.com/ocrad) (community)
- **Categories:** Lead generation, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 number validateds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

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

### Phone Number Validator & Formatter (Bulk, CSV, Dataset)

***

Clean a phone list in one run. Paste numbers, drop in a CSV, Excel file or Google Sheet, paste raw text, or point it at the results of any other Apify Actor, and get every number back **validated, formatted and labelled**:

- **Valid or not**, and why not (`TOO_SHORT`, `TOO_LONG`, `INVALID_NUMBER` …).
- **Ready-to-use formats**: E.164 (`+15148720311`) for CRMs and SMS tools, national, international and `tel:` links.
- **Line type**: mobile, landline, toll-free, premium rate, VoIP, shared cost, pager …
- **Where it is**: country, city, province or state, area code and time zones, so you call at the right hour.
- **Original carrier** for mobile ranges, where published.
- **Risk flags** before you dial or import: premium rate, toll-free, VoIP, fictional 555 numbers, a number from another country than your list, duplicates.

The same number written five different ways (`514-872-0311`, `(514) 872 0311`, `+1 514 872 0311` …) is recognised as **one number**: duplicates are removed and never charged.

Everything runs inside the Actor from the official numbering-plan data of 240+ countries: **no API key, no external service, nothing to set up**. It handles tens of thousands of numbers per minute.

***

#### **📋 Example Output**

Input `514 872-0311` with default country `CA`:

```json
{
  "input": "514 872-0311",
  "valid": true,
  "possible": true,
  "invalidReason": null,
  "e164": "+15148720311",
  "international": "+1 514-872-0311",
  "national": "(514) 872-0311",
  "rfc3966": "tel:+1-514-872-0311",
  "digitsOnly": "15148720311",
  "extension": null,
  "callingCode": 1,
  "nationalNumber": "5148720311",
  "areaCode": "514",
  "countryCode": "CA",
  "countryName": "Canada",
  "lineType": "FIXED_LINE_OR_MOBILE",
  "isMobile": true,
  "location": "Montreal, QC",
  "city": "Montreal",
  "region": "QC",
  "originalCarrier": null,
  "timeZones": ["America/Toronto"],
  "flags": [],
  "isDuplicate": false,
  "duplicateOf": null,
  "countrySource": "default",
  "sourceType": "list",
  "source": "phoneNumbers",
  "row": 1,
  "field": null,
  "validatedAt": "2026-11-07T20:59:16.416446+00:00"
}
```

A French mobile comes back as `"lineType": "MOBILE"`, `"originalCarrier": "SFR"`, `"national": "06 12 34 56 78"`. An invalid entry keeps the same columns, with `"valid": false` and the reason in `invalidReason` and `flags`.

In the US, Canada and the other +1 countries, mobile and landline numbers share the same ranges, so they are reported as `FIXED_LINE_OR_MOBILE`. Toll-free and premium-rate numbers are still told apart.

##### Files you also get

| File | What it is |
|------|------------|
| `valid-numbers.csv` | Valid, unique numbers only, ready for Excel or a CRM import (E.164, national, international, type, location, time zone, flags, source row) |
| `SUMMARY` | Counts: valid, invalid, duplicates, and breakdowns by country, line type, flag and source |

Both are in the run's key-value store, linked from the **Output** tab.

#### **🚩 Flags**

| Flag | Meaning |
|------|---------|
| `TOLL_FREE` | 1-800, 0800 … free to call, usually a business switchboard |
| `PREMIUM_RATE` | 1-900, 0899 … expensive for the caller |
| `VOIP` | Internet-based number range |
| `SHARED_COST`, `PERSONAL_NUMBER`, `PAGER`, `UAN`, `VOICEMAIL` | Special-purpose ranges |
| `FICTIONAL` | 555-0100 to 555-0199, reserved for films and examples in North America |
| `OTHER_COUNTRY` | Written without a country code but belongs to another country than your default (for example an 876 Jamaica number in a US list) |
| `DUPLICATE` | Same number seen earlier (only when Remove duplicates is off) |
| `TOO_SHORT`, `TOO_LONG`, `INVALID_LENGTH`, `INVALID_NUMBER`, `INVALID_COUNTRY_CODE`, `NO_COUNTRY`, `NOT_A_NUMBER` | Why a number is invalid |

#### **📥 Inputs you can mix in one run**

- **Phone numbers**: a list, one per line, in any format. A line holding several numbers (`514 555 1234; 438 555 9876`) is split.
- **Free text**: paste emails, notes or a page of text. Every phone number inside is found.
- **Files and pages**: CSV or TSV (comma, semicolon, tab), Excel `.xlsx`, JSON, TXT, a **Google Sheet** shared as "Anyone with the link", or a **web page** (its `tel:` links and visible numbers).
- **Apify datasets**: the dataset ID of another Actor's run, for example a real-estate, jobs or business-directory scraper. Phone fields are found automatically, including nested ones such as `agent.phones`.

Phone columns are detected by name in English and French (phone, tel, mobile, cell, fax, WhatsApp, téléphone, cellulaire, portable …). If your column has another name, list it in **Phone fields**.

**Country.** A number written with `+` or `00` is placed by its own country code. Otherwise the row's own country column is used (`country`, `countryCode` or `pays`: an ISO code, a name such as `Canada` or `France`, or a calling code such as `+33`), and then the **Default country**.

#### ⚙️ **Configuration**

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `phoneNumbers` | Array | `[]` | Numbers to validate, one per line. |
| `text` | String | | Free text to search for numbers. |
| `fileUrls` | Array | `[]` | Links to CSV, TSV, XLSX, JSON or TXT files, Google Sheets or web pages. Up to 50 MB each. |
| `datasetIds` | Array | `[]` | Apify dataset IDs to read numbers from. |
| `phoneFields` | Array | auto | Columns or fields holding the numbers. Dot paths work: `contact.mobile`. |
| `countryField` | String | auto | Column or field with each row's country. |
| `defaultCountry` | String | `US` | Country for numbers written without `+`: a 2-letter code (`CA`, `GB`, `FR`, `MA` …) or a name. |
| `locale` | String | `en` | Language of country, city and carrier names: `en` or `fr`. |
| `deduplicate` | Boolean | `true` | Keep each number once. Off = repeats are output with a `DUPLICATE` flag, free of charge. |
| `includeInvalid` | Boolean | `true` | Also output invalid numbers with the reason. Off = valid numbers only. |
| `keepSourceRecord` | Boolean | `false` | Attach the original row or dataset item to each result, to merge back into your list. |
| `maxNumbers` | Integer | `0` | Stop after this many unique numbers. 0 = no limit. |

At least one of `phoneNumbers`, `text`, `fileUrls` or `datasetIds` is needed.

##### Example Input

```json
{
  "fileUrls": [{ "url": "https://docs.google.com/spreadsheets/d/your-sheet-id/edit#gid=0" }],
  "datasetIds": ["your-scraper-dataset-id"],
  "defaultCountry": "CA",
  "locale": "fr",
  "includeInvalid": true,
  "keepSourceRecord": true
}
```

#### 💰 **Pricing**

Pay only for what you get:

| Event | Price | When |
|-------|-------|------|
| Run start | $0.002 | Once per run |
| Number validated | $0.0008 | Each unique number delivered, valid or invalid |

Duplicates, blank cells and invalid numbers you chose to skip (`includeInvalid` off) are **free**.

| Example | Cost |
|---------|------|
| 100 numbers | $0.082 |
| 1,000-row CSV | $0.802 |
| 10,000-lead list | $8.002 |

Set a **maximum cost per run** in the run options: the Actor stops cleanly at that limit and keeps everything validated so far.

#### **Use it from the API, MCP and AI agents**

Call it from any language with the Apify API, schedule it after your scrapers, or chain it with an integration so every new scraper run is cleaned automatically: pass the scraper's `defaultDatasetId` in `datasetIds`. It also works as a tool for AI agents through the Apify MCP server.

#### **Good to know**

- Validation checks that a number **can exist** under its country's numbering plan (right length, real area code and range, line type). It does not call the number, so it cannot tell whether a line is currently switched on.
- `originalCarrier` is the operator the range was first given to. Numbers can be moved to another operator since.

#### 💬 **Support and Feedback**

Reach out via Apify support channels or leave feedback on the Actor's page.

#### **Is it legal to validate phone numbers?**

Checking the format and numbering plan of a number is legal, and nothing is sent to the number or any third party. Phone numbers of individuals are personal data: process them only with a legitimate reason, and follow the privacy and anti-spam rules that apply to you (GDPR, PIPEDA, Quebec's Law 25, TCPA, CASL …). Consult your legal advisor if unsure.

# Actor input Schema

## `phoneNumbers` (type: `array`):

One number per line, in any format: +1 514 872 0311, (212) 555-0123, 06 12 34 56 78, 1-800-… A line holding several numbers (separated by ; | / or "or") is split.

## `text` (type: `string`):

Paste emails, notes, a web page or any text: every phone number inside it is found and validated.

## `fileUrls` (type: `array`):

Links to CSV/TSV, Excel (.xlsx), JSON, TXT files, a Google Sheet shared as "Anyone with the link", or a web page (its tel: links and visible numbers are read). Phone columns are detected by name (phone, tel, mobile, cell, fax, téléphone, cellulaire …) unless you set Phone fields.

## `datasetIds` (type: `array`):

Validate the phone numbers from another Actor's results: paste the dataset ID of a scraper run. Phone fields are detected automatically, including nested ones such as agent.phones.

## `phoneFields` (type: `array`):

Column or field names that hold the numbers, for files and datasets (dot paths work: contact.mobile). Leave empty to detect them automatically.

## `countryField` (type: `string`):

Column or field with each row's country (ISO code like CA, a name like Canada or France, or a calling code like +33). Detected automatically when it is called country, countryCode or pays. Used for numbers written without +.

## `defaultCountry` (type: `string`):

Country used for numbers written without + or 00 and with no country on their row. 2-letter code (US, CA, GB, FR, MA, AE …) or a country name.

## `locale` (type: `string`):

Language for country, city and carrier names.

## `deduplicate` (type: `boolean`):

Keep each number once, even when written in different formats. When off, repeats are output with a DUPLICATE flag. Duplicates are never charged.

## `includeInvalid` (type: `boolean`):

Also output invalid numbers with the reason (TOO_SHORT, INVALID_NUMBER …). Turn off to get valid numbers only; skipped numbers are not charged.

## `keepSourceRecord` (type: `boolean`):

Attach the full original row or dataset item to each result, to merge back into your list or CRM.

## `maxNumbers` (type: `integer`):

Stop after this many unique numbers. 0 = no limit.

## Actor input object example

```json
{
  "phoneNumbers": [
    "514 872-0311",
    "(212) 555-0123",
    "+44 20 7946 0958",
    "+33 6 12 34 56 78",
    "1-800-555-0199",
    "+1 514-872-0311",
    "12345"
  ],
  "defaultCountry": "US",
  "locale": "en",
  "deduplicate": true,
  "includeInvalid": true,
  "keepSourceRecord": false,
  "maxNumbers": 0
}
```

# Actor output Schema

## `input` (type: `string`):

Number exactly as given

## `valid` (type: `string`):

true when the number is valid for its country

## `possible` (type: `string`):

true when the length is plausible

## `invalidReason` (type: `string`):

TOO_SHORT, TOO_LONG, INVALID_LENGTH, INVALID_NUMBER, INVALID_COUNTRY_CODE, NO_COUNTRY or NOT_A_NUMBER

## `e164` (type: `string`):

E.164 format (+15148720311), best for CRMs and SMS tools

## `international` (type: `string`):

International format (+1 514-872-0311)

## `national` (type: `string`):

National format ((514) 872-0311)

## `rfc3966` (type: `string`):

tel: URI for click-to-call links

## `digitsOnly` (type: `string`):

Digits only with country code

## `extension` (type: `string`):

Extension, when given

## `callingCode` (type: `string`):

Country calling code (1, 33, 44 …)

## `nationalNumber` (type: `string`):

Number without the country code

## `areaCode` (type: `string`):

Area code (US, Canada and other +1 countries)

## `countryCode` (type: `string`):

ISO country code (CA, US, FR …)

## `countryName` (type: `string`):

Country name

## `lineType` (type: `string`):

MOBILE, FIXED_LINE, FIXED_LINE_OR_MOBILE, TOLL_FREE, PREMIUM_RATE, VOIP, SHARED_COST, PERSONAL_NUMBER, PAGER, UAN, VOICEMAIL

## `isMobile` (type: `string`):

true when the number is or can be a mobile

## `location` (type: `string`):

Place the number is assigned to

## `city` (type: `string`):

City

## `region` (type: `string`):

Province or state

## `timeZones` (type: `string`):

Time zones of the number

## `originalCarrier` (type: `string`):

Carrier the number range was first assigned to (numbers can be ported)

## `flags` (type: `string`):

Risk flags: TOLL_FREE, PREMIUM_RATE, VOIP, SHARED_COST, FICTIONAL, OTHER_COUNTRY, DUPLICATE and invalid reasons

## `isDuplicate` (type: `string`):

true when the same number appeared earlier

## `duplicateOf` (type: `string`):

E.164 of the first occurrence

## `countrySource` (type: `string`):

Where the country came from: international, record or default

## `sourceType` (type: `string`):

list, text, file or dataset

## `source` (type: `string`):

File link or dataset ID the number came from

## `row` (type: `string`):

Row or line number in the source

## `field` (type: `string`):

Column or field the number came from

## `sourceRecord` (type: `string`):

Original row or item (when Keep the original row is on)

## `validatedAt` (type: `string`):

When the number was validated (ISO)

# 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 = {
    "phoneNumbers": [
        "514 872-0311",
        "(212) 555-0123",
        "+44 20 7946 0958",
        "+33 6 12 34 56 78",
        "1-800-555-0199",
        "+1 514-872-0311",
        "12345"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ocrad/phone-number-validator-formatter").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 = { "phoneNumbers": [
        "514 872-0311",
        "(212) 555-0123",
        "+44 20 7946 0958",
        "+33 6 12 34 56 78",
        "1-800-555-0199",
        "+1 514-872-0311",
        "12345",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ocrad/phone-number-validator-formatter").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 '{
  "phoneNumbers": [
    "514 872-0311",
    "(212) 555-0123",
    "+44 20 7946 0958",
    "+33 6 12 34 56 78",
    "1-800-555-0199",
    "+1 514-872-0311",
    "12345"
  ]
}' |
apify call ocrad/phone-number-validator-formatter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ocrad/phone-number-validator-formatter"
        }
    }
}
```

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/YTaKMjQ6JbhfE54n2/builds/djcIjUpbujNUB1bqS/openapi.json
