JSON Array Merger

Concatenates two JSON arrays (A followed by B), with an optional dedupe mode that drops later items that are deeply equal to an earlier one, comparing objects regardless of key order. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-24

Overview

Introduction

Combining two JSON arrays, two pages of API results, two exported data sets, is a common but slightly fiddly task once you also need to avoid duplicate entries.

This tool concatenates two arrays and, optionally, removes later items that deeply duplicate an earlier one, so you don't have to write that comparison logic yourself.

What Is JSON Array Merger?

A merge tool that parses two JSON arrays (labeled A and B) and concatenates them, A's items first, then B's, with an optional dedupe pass afterward.

Deduplication compares items by deep value equality rather than by reference or a shallow check, so two structurally identical objects are recognized as duplicates even if they came from different sources and aren't the same JS object.

How JSON Array Merger Works

Both inputs are parsed independently, and each is required to be a JSON array at the top level. The tool then builds a combined array by spreading A followed by B.

When dedupe is enabled, each item is converted to a canonical form first, recursively sorting any object's keys, so key order can't cause two equal-but-differently-ordered objects to be treated as distinct, then JSON.stringify'd for a fast equality check. Items whose canonical form has already been seen are dropped; everything else is kept in its original A-then-B order.

When To Use JSON Array Merger

Use it to combine two pages of paginated API results, or two separately exported data files, into a single array.

Turn on dedupe when the two sources might overlap, for example merging this week's export with last week's, where some records legitimately appear in both.

Features

Advantages

  • Reports parse or type errors per side (A or B), so you know exactly which input to fix.
  • Dedupe compares by deep value equality, correctly catching duplicate objects regardless of key order.
  • Preserves original item order within each side.

Limitations

  • Dedupe compares whole items only; it can't dedupe by a specific key (like matching only on "id") while ignoring other differing fields.
  • Only merges exactly two arrays at a time; merging three or more requires running the tool twice.

Examples

Merging without dedupe

Input

A: [1, 2]
B: [2, 3]

Output

[
  1,
  2,
  2,
  3
]

Plain concatenation keeps the duplicate 2 since dedupe is off by default.

Merging with dedupe on

Input

A: [{"id":1},{"id":2}]
B: [{"id":2},{"id":3}]

Output

[
  { "id": 1 },
  { "id": 2 },
  { "id": 3 }
]

The second {"id":2} from B is dropped as a deep duplicate of the one already included from A.

Best Practices & Notes

Best Practices

  • Turn on dedupe whenever the two arrays might have come from overlapping time ranges or overlapping data pulls.
  • If you need to dedupe by a specific id field rather than the whole item, use Group JSON Array by that id first and take one item per group instead.
  • Use Compare JSON Arrays first if you want to inspect exactly what's shared vs. unique before merging.

Developer Notes

The dedupe check uses a Set of canonicalized JSON.stringify strings rather than an O(n²) pairwise deep-equality scan, so merge performance stays roughly linear in the combined array size even for larger inputs, at the cost of needing the canonicalize() pre-pass to make key order not matter to the string comparison.

JSON Array Merger Use Cases

  • Combining two pages of paginated API results into one array
  • Merging two exported data files that may share some overlapping records
  • Building a union data set from two separately maintained JSON arrays

Common Mistakes

  • Expecting dedupe to match on a single field like "id"; it compares entire items, so two records with the same id but a different field elsewhere are not treated as duplicates.
  • Forgetting that with dedupe on, the surviving copy of a duplicate is always the one from A, not B.

Tips

  • For a full breakdown of what's unique to each side vs. shared, use Compare JSON Arrays instead of merging.
  • Merging JSON objects instead of arrays? Use Merge JSON Objects.

References

Frequently Asked Questions