# JSON Dataset Merger & Deduplicator (`khakied_marzipan/json-dataset-merger-deduplicator`) Actor

Combine multiple JSON arrays into one deduplicated dataset. Remove duplicates using a field you choose, retain the first matching record, and simplify data preparation for analysis, reporting, and automation workflows.

- **URL**: https://apify.com/khakied_marzipan/json-dataset-merger-deduplicator.md
- **Developed by:** [Fadi Hathwa](https://apify.com/khakied_marzipan) (community)
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 100 cleaned records

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

## JSON Dataset Merger & Deduplicator

Turn multiple JSON record arrays into one deduplicated dataset.

Choose a field such as `id`, `email`, or `url` to identify duplicates. The Actor keeps the first matching record, preserves input order, and returns the combined results for analysis, reporting, or your next automation step.

Optional settings enable case-insensitive matching and basic contact-field cleanup.

### 1. Quick start

1. Provide your JSON record arrays in `datasets`.
2. Choose one top-level field as `dedupeField`.
3. Start the Actor.
4. Open Output to view the results.

#### Example input

````json
{
  "datasets": [
      [
            { "id": "1", "name": "Alice" },
                  { "id": "2", "name": "Bob" }
                      ],
                          [
                                { "id": "1", "name": "Alice duplicate" },
                                      { "id": "3", "name": "Charlie" }
                                          ]
                                            ],
                                              "dedupeField": "id",
                                                "caseInsensitiveDedupe": false,
                                                  "sanitizeContacts": false
                                                  }
                                                  ```

                                                  ### Expected output

                                                  ```json
                                                  [
                                                    { "id": "1", "name": "Alice" },
                                                      { "id": "2", "name": "Bob" },
                                                        { "id": "3", "name": "Charlie" }
                                                        ]
                                                        ```

                                                        Four input records become three output records. The first record with ID `"1"` is retained; the later duplicate is removed.

                                                        ## 2. Input settings

                                                        | Setting | Required | Description |
                                                        | --- | --- | --- |
                                                        | `datasets` | Yes | An array containing arrays of JSON objects. |
                                                        | `dedupeField` | Yes | One top-level field used to identify duplicates. |
                                                        | `caseInsensitiveDedupe` | No | Defaults to `false`. Ignores letter case and surrounding spaces when comparing text keys. |
                                                        | `sanitizeContacts` | No | Defaults to `false`. Trims text and applies basic email and phone formatting cleanup. |

                                                        ### Case-insensitive matching

                                                        Enable `caseInsensitiveDedupe` to treat values such as `"ABC-1"` and `" abc-1 "` as the same key.

                                                        This setting changes how keys are compared; it does not itself rewrite the retained record.

                                                        ### Contact-field cleanup

                                                        When `sanitizeContacts` is enabled, the Actor:

                                                        - Trims leading and trailing spaces from text values.
                                                        - Lowercases email values in recognized email fields.
                                                        - Removes formatting from recognized phone values where applicable, preserving a leading `+`.

                                                        Contact cleanup is not contact verification. It does not check email deliverability, verify phone ownership, or add country codes.

                                                        Cleanup is applied before deduplication, so it can affect matching when the selected key is a cleaned field.

                                                        ## 3. Matching rules and limits

                                                        ### Duplicate handling

                                                        - Records are processed in the order supplied.
                                                        - The first record with each matching key is retained.
                                                        - Later matching records are removed, not merged field by field.
                                                        - Missing, null, and empty-string keys are retained rather than deduplicated.
                                                        - Matching is case-sensitive by default.
                                                        - Value types matter: the number `1` and the string `"1"` are different keys.

                                                        ### Supported input

                                                        - Up to 1,000 input records per run across all arrays.
                                                        - Up to 1 MiB of serialized JSON input.
                                                        - Each record must be a JSON object.
                                                        - Deduplication keys may be strings, numbers, or booleans; null and missing keys are also accepted.

                                                        ### Not supported

                                                        - Fetching Apify datasets by ID.
                                                        - Importing CSV files or downloading data from URLs.
                                                        - Website scraping.
                                                        - Deduplication by multiple fields or nested field paths.
                                                        - Fuzzy matching or automatic identity resolution.

                                                        Supply the records directly in the JSON input.

                                                        ## 4. Results and pricing

                                                        ### Results

                                                        The Actor saves delivered records to the run's default dataset.

                                                        A `SUMMARY` record in the default key-value store provides processing counts and billing-related information.

                                                        If the run's spending limit prevents delivery of another batch, the output may be partial. Check `SUMMARY` before treating the output as complete.

                                                        ### Pricing

                                                        The configured price is **$0.02 per batch of up to 100 delivered output records**, plus the Actor-start fee displayed in the Pricing tab.

                                                        A partial batch counts as one full batch. Removed duplicates do not count toward the delivered-record total.

                                                        | Delivered records | Billable batches | Batch charges |
                                                        | --- | --- | --- |
                                                        | 0 | 0 | $0.00 |
                                                        | 1–100 | 1 | $0.02 |
                                                        | 101–200 | 2 | $0.04 |
                                                        | 1,000 | 10 | $0.20 |

                                                        The amounts above exclude the Actor-start fee.

                                                        **Understanding the Store price:** `$20 per 1,000 events` means 1,000 batches of up to 100 records each—not 1,000 individual records.

                                                        The Pricing tab shows the current rates.

                                                        ## 5. Troubleshooting and support

                                                        - **Input rejected:** Check that `datasets` contains arrays of objects, `dedupeField` is a non-empty string, and the input stays within the limits.
                                                        - **Duplicates remain:** Check the selected field, differences in value types, and the case-insensitive setting.
                                                        - **Fewer results than expected:** Check the run log and `SUMMARY`, including whether the spending limit stopped delivery.
                                                        - **Contact values look unchanged:** Cleanup depends on recognized field names and supported value formats; it is not a general-purpose contact validator.

                                                        To report a problem, use the Actor's Issues tab. Include the error message, relevant settings, and a small anonymized input example.

                                                        Never include passwords, API tokens, or sensitive personal information in a public issue.



# Actor input Schema

## `datasets` (type: `array`):

Enter an array of arrays of JSON records.
## `dedupeField` (type: `string`):

Field used to identify duplicates, such as id or email.
## `sanitizeContacts` (type: `boolean`):

Trim text and normalize email and phone fields.
## `caseInsensitiveDedupe` (type: `boolean`):

Ignore letter case and surrounding spaces in text keys.

## Actor input object example

```json
{
  "datasets": [
    [
      {
        "id": "1",
        "name": "Alice"
      },
      {
        "id": "2",
        "name": "Bob"
      }
    ],
    [
      {
        "id": "1",
        "name": "Alice duplicate"
      }
    ]
  ],
  "dedupeField": "id",
  "sanitizeContacts": false,
  "caseInsensitiveDedupe": false
}
````

# Actor output Schema

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

Merged and deduplicated records stored in the default dataset.

# 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 = {
    "datasets": [
        [
            {
                "id": "1",
                "name": "Alice"
            },
            {
                "id": "2",
                "name": "Bob"
            }
        ],
        [
            {
                "id": "1",
                "name": "Alice duplicate"
            }
        ]
    ],
    "dedupeField": "id"
};

// Run the Actor and wait for it to finish
const run = await client.actor("khakied_marzipan/json-dataset-merger-deduplicator").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 = {
    "datasets": [
        [
            {
                "id": "1",
                "name": "Alice",
            },
            {
                "id": "2",
                "name": "Bob",
            },
        ],
        [{
                "id": "1",
                "name": "Alice duplicate",
            }],
    ],
    "dedupeField": "id",
}

# Run the Actor and wait for it to finish
run = client.actor("khakied_marzipan/json-dataset-merger-deduplicator").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 '{
  "datasets": [
    [
      {
        "id": "1",
        "name": "Alice"
      },
      {
        "id": "2",
        "name": "Bob"
      }
    ],
    [
      {
        "id": "1",
        "name": "Alice duplicate"
      }
    ]
  ],
  "dedupeField": "id"
}' |
apify call khakied_marzipan/json-dataset-merger-deduplicator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,khakied_marzipan/json-dataset-merger-deduplicator"
        }
    }
}
```

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/B5WxoWSsmB8PETocc/builds/RIhyONm1TdZXqyT7p/openapi.json
