Remove duplicates from a JSON array

Paste a JSON array below and dedupe it, either whole-object or by a key path like user.id. Order is preserved and the first occurrence is kept. All in your browser; use the API for pipelines.

Drop a .xlsx / .csv file here or

Processed locally. Check your Network tab: no uploads.

In code, for comparison

In JavaScript you'd write [...new Map(arr.map(o => [o.user.id, o])).values()], which keeps the last occurrence, not the first: a classic subtle bug. jq's unique_by sorts your array. This tool (and the API's json mode) keeps first occurrence and original order, which is almost always what you want.

FAQ

Frequently asked questions

How do I remove duplicate objects from a JSON array?

Paste the array into the tool above. Leave the key path empty to dedupe identical objects, or give a path like user.id to collapse objects sharing that value. First occurrence wins.

Can I do this with jq?

Yes: `jq 'unique_by(.user.id)'`. But jq's unique_by sorts the output; this tool preserves the original array order.

What about nested keys?

Use dot notation: user.address.zip walks nested objects.

Last updated