# Phone Number Wrangler (`rl1987/phone-number-wrangler`) Actor

Validate, format, parse, and extract fields from phone numbers using Google's libphonenumber — batch phone-number wrangling toolkit.

- **URL**: https://apify.com/rl1987/phone-number-wrangler.md
- **Developed by:** [R.L.](https://apify.com/rl1987) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / actor run

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

**Phone Number Wrangler** is a batch phone-number-processing toolkit for the [Apify platform](https://apify.com), built on Google's [libphonenumber](https://github.com/google/libphonenumber) via the [`phonenumbers`](https://pypi.org/project/phonenumbers/) Python port. Feed it a list of phone numbers and pick one of four operations — validate, format, parse (full breakdown), or extract a single field — and get structured JSON back, one row per input number. Run it via the [Apify Console](https://console.apify.com), the [API](https://docs.apify.com/api/v2), or on a [schedule](https://docs.apify.com/platform/schedules), with full run history, monitoring, and integrations (Zapier, Make, Google Sheets, webhooks) included.

### Why use Phone Number Wrangler?

Cleaning up phone numbers scraped from a website, validating leads before a dialer campaign, or normalizing a CRM export usually means pulling in `phonenumbers` yourself and writing glue code around it. Phone Number Wrangler packages the common operations into a single Actor so you can:

- **Validate leads in bulk** before handing them to a dialer or SMS provider (`validate`) — get `valid`/`possible` flags plus a canonical E.164 form.
- **Normalize numbers to a consistent format** for storage or deduplication (`format`) — E.164, international, national, or RFC 3966 (`tel:` URI).
- **Get a full breakdown of every number** — country code, national significant number, region, line type (mobile/fixed/toll-free/VOIP/...), carrier, approximate location, and timezone(s) (`parse`).
- **Pull out just one field** — e.g. only the region code or only the carrier — from a batch of numbers for reporting or filtering (`extract`).

### How to use Phone Number Wrangler

1. Open the Actor's **Input** tab.
2. Choose an **Operation**: `validate`, `format`, `parse`, or `extract`.
3. Paste your list of phone numbers into **Phone numbers**.
4. If any number isn't already in `+`-prefixed international form, set **Default region** (e.g. `US`) so it can be interpreted correctly.
5. Fill in the fields relevant to your chosen operation (see [Input](#input) below, and [Examples](#examples) for a full input/output pair per operation — irrelevant fields are ignored).
6. Click **Start**. Results land in the run's default **Dataset**, one row per input number, downloadable as JSON, CSV, Excel, or HTML.

### Input

All fields live in one flat input object — an `operation` selector, the shared `numbers` list, and a handful of operation-specific parameters that apply uniformly to every number in that run. See the **Input** tab for the full schema with descriptions.

| Field | Used by | Description |
|---|---|---|
| `operation` | all | `validate` | `format` | `parse` | `extract` |
| `numbers` | all | The phone numbers to process |
| `defaultRegion` | all | Two-letter region code (e.g. `US`, `GB`) used to interpret numbers not already in `+`-prefixed international form |
| `format` | `format` | `E164` | `INTERNATIONAL` | `NATIONAL` | `RFC3966` |
| `field` | `extract` | `country_code` | `national_number` | `extension` | `region_code` | `number_type` | `carrier` | `location` | `timezones` |
| `language` | `parse`, `extract` (`field=carrier`/`location`) | Two-letter language code for carrier name and geographic description |

### Output

Every run pushes one dataset item per input number: `{ operation, input, result, error }`. `error` is `null` on success, so a single malformed number never aborts the run.

### Examples

Each pair below is a complete Actor input alongside the corresponding dataset row it produces.

#### `validate`

Input:

```json
{
  "operation": "validate",
  "numbers": ["+14155552671", "+1234"]
}
```

Output (first row):

```json
{
  "operation": "validate",
  "input": "+14155552671",
  "result": { "valid": true, "possible": true, "e164": "+14155552671" },
  "error": null
}
```

#### `format`

Input:

```json
{
  "operation": "format",
  "numbers": ["(415) 555-2671"],
  "defaultRegion": "US",
  "format": "RFC3966"
}
```

Output:

```json
{
  "operation": "format",
  "input": "(415) 555-2671",
  "result": "tel:+1-415-555-2671",
  "error": null
}
```

#### `parse`

Input:

```json
{
  "operation": "parse",
  "numbers": ["+14155552671"]
}
```

Output:

```json
{
  "operation": "parse",
  "input": "+14155552671",
  "result": {
    "valid": true,
    "possible": true,
    "country_code": 1,
    "national_number": "4155552671",
    "extension": null,
    "region_code": "US",
    "number_type": "FIXED_LINE_OR_MOBILE",
    "e164": "+14155552671",
    "international": "+1 415-555-2671",
    "national": "(415) 555-2671",
    "rfc3966": "tel:+1-415-555-2671",
    "carrier": null,
    "location": "San Francisco, CA",
    "timezones": ["America/Los_Angeles"]
  },
  "error": null
}
```

#### `extract`

Input:

```json
{
  "operation": "extract",
  "numbers": ["+14155552671"],
  "field": "number_type"
}
```

Output:

```json
{
  "operation": "extract",
  "input": "+14155552671",
  "result": "FIXED_LINE_OR_MOBILE",
  "error": null
}
```

### Data table

| Field | Type | Present when | Description |
|---|---|---|---|
| `operation` | string | always | Operation that produced this row |
| `input` | string | always | The original input phone number |
| `result` | varies | on success | Validation object (`validate`), formatted string (`format`), full breakdown object (`parse`), or field value (`extract`) |
| `error` | string | null | always | Failure reason for this number, or `null` |

### Pricing / cost estimation

Phone Number Wrangler does pure in-memory number parsing against a bundled metadata database — no network requests, no browser, no proxy usage. Cost is driven entirely by compute time, which is minimal (typically well under 100ms per number). On the [Apify Free plan](https://apify.com/pricing), you can process tens of thousands of numbers per run within the platform's free monthly compute unit allowance.

### Tips / advanced options

- Numbers already in `+`-prefixed international form (e.g. `+14155552671`) don't need `defaultRegion` — it's only used to interpret national-format numbers like `(415) 555-2671`.
- `carrier` and `location` lookups mainly cover mobile numbers in supported countries; landlines and some regions legitimately return `null`.
- `number_type` values follow libphonenumber's own enum: `FIXED_LINE`, `MOBILE`, `FIXED_LINE_OR_MOBILE`, `TOLL_FREE`, `PREMIUM_RATE`, `SHARED_COST`, `VOIP`, `PERSONAL_NUMBER`, `PAGER`, `UAN`, `VOICEMAIL`, `UNKNOWN`.
- `validate`'s `possible` flag is a cheaper length/prefix sanity check; `valid` runs the full metadata-backed validation and is stricter.

### Background reading

This Actor is a thin wrapper around Google's libphonenumber. Related reading:

- [google/libphonenumber](https://github.com/google/libphonenumber) — the canonical phone-number handling library this Actor is built on
- [daviddrysdale/python-phonenumbers](https://github.com/daviddrysdale/python-phonenumbers) — the Python port (`phonenumbers` on PyPI) used here
- [E.164 (Wikipedia)](https://en.wikipedia.org/wiki/E.164) — the international public telecommunication numbering plan format
- [ITU-T Recommendation E.164](https://www.itu.int/rec/T-REC-E.164/en) — the official numbering plan spec this format is named after

### FAQ, limitations, and support

- This Actor only processes phone numbers you provide — it does not dial, send SMS, or contact any number.
- Metadata (valid ranges, carrier names, geographic descriptions) comes bundled with the `phonenumbers` library version pinned in this Actor and is refreshed on dependency updates, not in real time.
- Found a bug or want another operation (bulk deduplication, country-code presets, custom formatting)? Open an issue on the Actor's Issues tab — these are tracked as candidate follow-ups.

### Data pipeline toolkit

Part of the **Data pipeline toolkit** — small, chainable Actors for cleaning, transforming, and generating data inside a larger pipeline:

- [jq Helper – transform JSON with jq](https://apify.com/rl1987/jq-helper) — Run jq programs over inline JSON or a linked Apify dataset.
- [DuckDB Helper – SQL over CSV, JSON, Parquet, Excel, SQLite](https://apify.com/rl1987/duckdb-wrapper) — Run a DuckDB SQL query over remote/local files, push results to a dataset.
- [Regex Helper](https://apify.com/rl1987/regex-helper) — Apply named regular expressions to strings, extract structured matches.
- [URL Wrangler](https://apify.com/rl1987/url-wrangler) — Join, decompose, and rewrite URLs and query params in batch.
- [ZIP Code Helper](https://apify.com/rl1987/zip-code-helper) — Resolves US ZIP codes into city, state, county, and more.
- [Postal Address Normaliser](https://apify.com/rl1987/postal-address-normaliser) — Parses and normalises postal addresses using libpostal.
- [UUID Generator](https://apify.com/rl1987/uuid-generator) — Generate bulk UUIDs (v1, v3, v4, v5, v7) on demand.
- [Secure Password & Passphrase Generator](https://apify.com/rl1987/password-generator) — Generate secure passwords and diceware passphrases per NIST guidance.
- [Thumbnail Maker](https://apify.com/rl1987/thumbnail-maker) — Generates thumbnails from image URLs using ImageMagick.
- [Katana Web Crawler (ProjectDiscovery)](https://apify.com/rl1987/pd-katana) — Crawl websites with Katana, stream results as JSONL.
- [ProjectDiscovery Notify](https://apify.com/rl1987/pd-notify) — Stream records to Slack, Discord, Telegram, Email, and more.

### Did you find this useful?

⭐ Rate this actor on Apify! Your feedback helps other users find it and helps us keep improving it.

# Actor input Schema

## `operation` (type: `string`):

Which phone-number-wrangling operation to run over the number list.

## `numbers` (type: `array`):

The phone numbers to process, e.g. "+14155552671" or a national number combined with Default region.

## `defaultRegion` (type: `string`):

Two-letter region code (e.g. "US", "GB") used to interpret numbers that don't start with "+" or "00". Not needed for numbers already in E.164/international form.

## `format` (type: `string`):

Format to render the number in.

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

Which field to extract from every number.

## `language` (type: `string`):

Two-letter language code for the carrier name and geographic description, e.g. "en", "es".

## Actor input object example

```json
{
  "operation": "parse",
  "numbers": [
    "+14155552671",
    "(415) 555-2671"
  ],
  "defaultRegion": "US",
  "format": "E164",
  "field": "region_code",
  "language": "en"
}
```

# 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 = {
    "numbers": [
        "+14155552671",
        "(415) 555-2671"
    ],
    "defaultRegion": "US"
};

// Run the Actor and wait for it to finish
const run = await client.actor("rl1987/phone-number-wrangler").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 = {
    "numbers": [
        "+14155552671",
        "(415) 555-2671",
    ],
    "defaultRegion": "US",
}

# Run the Actor and wait for it to finish
run = client.actor("rl1987/phone-number-wrangler").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 '{
  "numbers": [
    "+14155552671",
    "(415) 555-2671"
  ],
  "defaultRegion": "US"
}' |
apify call rl1987/phone-number-wrangler --silent --output-dataset

```

## MCP server setup

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

```

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/yJhSonHHRI7Z8BY45/builds/BFfWivKi8qOkZY04H/openapi.json
