# Data Cleaner (`parsebird/data-cleaner`) Actor

Clean messy data — remove nulls, normalize case, trim whitespace, format phone numbers and emails, extract domains, convert types, and more. Works with Apify datasets or direct JSON input.

- **URL**: https://apify.com/parsebird/data-cleaner.md
- **Developed by:** [ParseBird](https://apify.com/parsebird) (community)
- **Categories:** Agents, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.49 / 1,000 items cleaneds

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

### Data Cleaner

Clean messy data — remove nulls, normalize case, trim whitespace, format phone numbers and emails, extract domains, convert types, and more. Works with Apify datasets or direct JSON input. The first general-purpose data cleaner on Apify.

<table><tr>
<td style="border-left:4px solid #2563EB;padding:12px 16px;font-weight:600">Clean messy scraped data in one step — trim whitespace, normalize casing, format phone numbers to E.164, lowercase emails, extract domains from URLs, convert strings to numbers, remove null rows, and deduplicate.</td>
</tr></table>

<br>

<table>
<tr>
<td colspan="3" style="padding:10px 14px;background:#2563EB;border:none;border-radius:4px 4px 0 0">
<span style="color:#FFFFFF;font-size:14px;font-weight:700;letter-spacing:0.5px">ParseBird Infra Suite</span>
<span style="color:#BFDBFE;font-size:13px">&nbsp;&nbsp;&bull;&nbsp;&nbsp;Utility tools for data pipelines</span>
</td>
</tr>
<tr>
<td style="padding:10px 14px;border:1px solid #E7E5E4;border-radius:0 0 0 4px;border-right:none;border-top:none;vertical-align:top;width:33%">
&#128279; &nbsp;<a href="https://apify.com/parsebird/http-request-actor" style="color:#1C1917;text-decoration:none;font-weight:700;font-size:13px">HTTP Request</a><br>
<span style="color:#78716C;font-size:11px">Send API calls from the cloud</span>
</td>
<td style="padding:10px 14px;border:1px solid #E7E5E4;border-right:none;border-top:none;vertical-align:top;width:33%">
&#128218; &nbsp;<a href="https://apify.com/parsebird/dataset-deduplicator" style="color:#1C1917;text-decoration:none;font-weight:700;font-size:13px">Data Deduplicator</a><br>
<span style="color:#78716C;font-size:11px">Merge & deduplicate datasets by any field</span>
</td>
<td style="padding:10px 14px;border:1px solid #E7E5E4;border-radius:0 0 4px 0;border-top:none;vertical-align:top;width:33%;background:#DBEAFE">
&#128481; &nbsp;<a href="https://apify.com/parsebird/data-cleaner" style="color:#2563EB;text-decoration:none;font-weight:700;font-size:13px">Data Cleaner</a><br>
<span style="color:#2563EB;font-size:11px;font-weight:600">&#10148; You are here</span>
</td>
</tr>
</table>

##### Copy to your AI assistant

Copy this block into ChatGPT, Claude, Cursor, or any LLM to start using this actor.

```
parsebird/data-cleaner on Apify. Call: ApifyClient("TOKEN").actor("parsebird/data-cleaner").call(run_input={...}), then client.dataset(run["defaultDatasetId"]).list_items().items for cleaned results. Key inputs: datasetId (string, Apify dataset ID), jsonData (array of objects, direct JSON input), operations (array of {field, action, options} — required), outputDatasetId (string, optional), maxItems (integer, default 1000000). Actions: trim_whitespace, normalize_case (options: {case: "lower"|"upper"|"title"}), format_email, format_phone (options: {countryCode: "US"}), extract_domain, to_number, to_date, fill_nulls (options: {value: "..."}), remove_nulls, remove_duplicates, replace_value (options: {find, replace}). Full actor spec: fetch build via GET https://api.apify.com/v2/acts/parsebird~data-cleaner (Bearer TOKEN). Get token: https://console.apify.com/account/integrations
```

### What does Data Cleaner do?

This Actor takes messy scraped or imported data and applies a configurable pipeline of cleaning operations. Each operation targets a specific field and transforms its values — trimming whitespace, normalizing case, formatting phone numbers, and more.

Use cases:

- **CRM cleanup** — normalize names, emails, and phone numbers before import
- **Lead list hygiene** — remove rows with missing emails, deduplicate by company
- **Post-scrape processing** — extract domains from URLs, convert price strings to numbers
- **Data pipeline prep** — standardize data format before analysis or export

### Supported operations

| Action | Description | Options | Before | After |
|--------|-------------|---------|--------|-------|
| `trim_whitespace` | Remove leading/trailing spaces | — | `"  John Doe  "` | `"John Doe"` |
| `normalize_case` | Convert to lower/upper/title case | `{"case": "title"}` | `"john doe"` | `"John Doe"` |
| `format_email` | Lowercase and trim emails | — | `"  JOHN@CO.COM  "` | `"john@co.com"` |
| `format_phone` | Normalize to E.164 format | `{"countryCode": "US"}` | `"(555) 123-4567"` | `"+15551234567"` |
| `extract_domain` | Extract domain from URL or email | — | `"https://www.example.com/page"` | `"example.com"` |
| `to_number` | Convert string to number | — | `"$1,234,567"` | `1234567` |
| `to_date` | Parse date to ISO 8601 | — | `"March 15, 2024"` | `"2024-03-15T00:00:00"` |
| `fill_nulls` | Replace null/empty with default | `{"value": "N/A"}` | `null` | `"N/A"` |
| `remove_nulls` | Remove rows where field is null/empty | — | *(row removed)* | — |
| `remove_duplicates` | Deduplicate by this field | — | *(duplicate removed)* | — |
| `replace_value` | Find and replace text | `{"find": "Inc.", "replace": "Inc"}` | `"Acme Inc."` | `"Acme Inc"` |

### Input parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `datasetId` | string | No\* | — | Apify dataset ID to clean |
| `jsonData` | array | No\* | — | Direct JSON array of objects to clean |
| `operations` | array | **Yes** | — | List of `{field, action, options}` cleaning operations |
| `outputDatasetId` | string | No | — | Named output dataset (defaults to run dataset) |
| `maxItems` | integer | No | `1000000` | Max items to process |

\*Provide either `datasetId` or `jsonData` (or both).

### Operations format

Each operation is a JSON object with:

```json
{
    "field": "email",
    "action": "format_email",
    "options": {}
}
```

Operations are applied in order. You can chain multiple operations on the same field:

```json
[
    {"field": "name", "action": "trim_whitespace"},
    {"field": "name", "action": "normalize_case", "options": {"case": "title"}},
    {"field": "email", "action": "format_email"},
    {"field": "phone", "action": "format_phone", "options": {"countryCode": "US"}},
    {"field": "website", "action": "extract_domain"},
    {"field": "revenue", "action": "to_number"},
    {"field": "email", "action": "remove_nulls"}
]
```

### Before and after example

**Input (dirty data)**

```json
[
    {"name": "  john doe  ", "email": "  JOHN@EXAMPLE.COM  ", "phone": "(555) 123-4567", "website": "https://www.example.com/about", "revenue": "$1,234,567"},
    {"name": "JANE SMITH", "email": "Jane.Smith@Company.IO", "phone": "555.987.6543", "website": "info@company.io", "revenue": "2345678"},
    {"name": "", "email": null, "phone": "1-800-555-0199", "website": "company.io", "revenue": "$99.99"},
    {"name": "bob wilson", "email": "bob@test.com", "phone": "+14155550100", "website": "https://test.com/page?id=1", "revenue": "not a number"}
]
```

**Output (cleaned data)**

```json
[
    {"name": "John Doe", "email": "john@example.com", "phone": "+15551234567", "website": "example.com", "revenue": 1234567},
    {"name": "Jane Smith", "email": "jane.smith@company.io", "phone": "+15559876543", "website": "company.io", "revenue": 2345678},
    {"name": "Bob Wilson", "email": "bob@test.com", "phone": "+14155550100", "website": "test.com", "revenue": "not a number"}
]
```

Row 3 was removed (null email with `remove_nulls`). All names are title-cased, emails lowercased, phones in E.164, domains extracted, and revenues converted to numbers.

### How to use via API

**Python**

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")

run = client.actor("parsebird/data-cleaner").call(run_input={
    "datasetId": "YOUR_DATASET_ID",
    "operations": [
        {"field": "email", "action": "format_email"},
        {"field": "name", "action": "trim_whitespace"},
        {"field": "name", "action": "normalize_case", "options": {"case": "title"}},
        {"field": "phone", "action": "format_phone", "options": {"countryCode": "US"}},
    ],
})

items = client.dataset(run["defaultDatasetId"]).list_items().items
print(f"Cleaned items: {len(items)}")
```

**cURL**

```bash
curl -X POST "https://api.apify.com/v2/acts/parsebird~data-cleaner/runs?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonData": [
        {"name": "  JOHN DOE  ", "email": "  JOHN@CO.COM  "}
    ],
    "operations": [
        {"field": "name", "action": "trim_whitespace"},
        {"field": "name", "action": "normalize_case", "options": {"case": "title"}},
        {"field": "email", "action": "format_email"}
    ]
  }'
```

### Output

Cleaned items retain their original structure. A `stats` key is stored in the key-value store:

```json
{
    "totalLoaded": 5000,
    "totalCleaned": 4800,
    "operationsApplied": 7,
    "fieldsCleaned": 5,
    "totalChanges": 15200
}
```

### Pricing

This Actor uses a pay-per-event pricing model.

| Event | Price per event | Price per 1,000 |
|-------|----------------|-----------------|
| `items-cleaned` | $0.00149 | **$1.49** |

Charged per 1,000 items loaded. Platform compute costs are additional.

# Changelog

This Actor's version history is a separate document: https://apify.com/parsebird/data-cleaner/changelog.md

# Actor input Schema

## `datasetId` (type: `string`):

Apify dataset ID to load and clean. Leave empty if providing data via jsonData.

## `jsonData` (type: `array`):

Direct JSON array of objects to clean. Use this instead of datasetId for ad-hoc cleaning.

## `operations` (type: `array`):

List of cleaning operations to apply. Each operation specifies a field, an action, and optional settings. Operations are applied in order.

## `outputDatasetId` (type: `string`):

Optional named dataset for output. If empty, results go to the default run dataset.

## `maxItems` (type: `integer`):

Maximum number of items to process.

## Actor input object example

```json
{
  "jsonData": [
    {
      "name": "  john doe  ",
      "email": "  JOHN@EXAMPLE.COM  "
    },
    {
      "name": "JANE SMITH",
      "email": "Jane.Smith@Company.IO"
    },
    {
      "name": "bob wilson",
      "email": "bob@test.com"
    }
  ],
  "operations": [
    {
      "field": "email",
      "action": "format_email"
    },
    {
      "field": "name",
      "action": "trim_whitespace"
    },
    {
      "field": "name",
      "action": "normalize_case",
      "options": {
        "case": "title"
      }
    }
  ],
  "maxItems": 1000000
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

# 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 = {
    "jsonData": [
        {
            "name": "  john doe  ",
            "email": "  JOHN@EXAMPLE.COM  "
        },
        {
            "name": "JANE SMITH",
            "email": "Jane.Smith@Company.IO"
        },
        {
            "name": "bob wilson",
            "email": "bob@test.com"
        }
    ],
    "operations": [
        {
            "field": "email",
            "action": "format_email"
        },
        {
            "field": "name",
            "action": "trim_whitespace"
        },
        {
            "field": "name",
            "action": "normalize_case",
            "options": {
                "case": "title"
            }
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("parsebird/data-cleaner").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 = {
    "jsonData": [
        {
            "name": "  john doe  ",
            "email": "  JOHN@EXAMPLE.COM  ",
        },
        {
            "name": "JANE SMITH",
            "email": "Jane.Smith@Company.IO",
        },
        {
            "name": "bob wilson",
            "email": "bob@test.com",
        },
    ],
    "operations": [
        {
            "field": "email",
            "action": "format_email",
        },
        {
            "field": "name",
            "action": "trim_whitespace",
        },
        {
            "field": "name",
            "action": "normalize_case",
            "options": { "case": "title" },
        },
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("parsebird/data-cleaner").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 '{
  "jsonData": [
    {
      "name": "  john doe  ",
      "email": "  JOHN@EXAMPLE.COM  "
    },
    {
      "name": "JANE SMITH",
      "email": "Jane.Smith@Company.IO"
    },
    {
      "name": "bob wilson",
      "email": "bob@test.com"
    }
  ],
  "operations": [
    {
      "field": "email",
      "action": "format_email"
    },
    {
      "field": "name",
      "action": "trim_whitespace"
    },
    {
      "field": "name",
      "action": "normalize_case",
      "options": {
        "case": "title"
      }
    }
  ]
}' |
apify call parsebird/data-cleaner --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,parsebird/data-cleaner"
        }
    }
}
```

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/P1rFcvewTs3R14n7j/builds/Ok42iWOYurQxaDj5w/openapi.json
