Compare Array of Objects Online

Paste two arrays of JSON objects. See which properties were added, removed, or changed — field by field.

🔒 100% private — runs entirely in your browser

or try sample data

What is Array of Objects Comparison?

Comparing arrays of objects is one of the most common and most challenging operations in software development. Unlike simple arrays of strings or numbers, object arrays require deep structural comparison — every key-value pair, at every nesting level, in every element must be checked. This tool performs that comparison visually, showing you exactly which objects were added or removed, and precisely which properties changed within modified objects.

Object array comparison arises in countless real-world scenarios. When comparing API response payloads across versions, you need to see which user records gained new fields or changed values. When reviewing database migration results, comparing exported rows before and after reveals whether transformations applied correctly. In frontend development, diffing component state arrays (e.g., a list of todo items or shopping cart entries) helps diagnose why a re-render produced unexpected output.

Paste your arrays of objects as JSON. Each object should use standard JSON syntax with double-quoted keys: [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]. The tool compares objects by position in the array by default. Enable "Ignore array order" when objects may appear in a different sequence between the two arrays. All comparison logic runs in your browser — your data is never sent anywhere.

Comparing Object Arrays — Code Examples

JavaScript — JSON.stringify for shallow comparison

const arr1 = [ { id: 1, name: "Alice", role: "admin" }, { id: 2, name: "Bob", role: "user" }
];
const arr2 = [ { id: 1, name: "Alice", role: "superadmin" }, { id: 3, name: "Charlie", role: "user" }
]; // Quick check: are the arrays identical?
const areEqual = JSON.stringify(arr1) === JSON.stringify(arr2);
console.log(areEqual); // false // Find objects in arr1 not present in arr2 (by id)
const ids2 = new Set(arr2.map(o => o.id));
const removed = arr1.filter(o => !ids2.has(o.id));
console.log(removed); // [{id: 2, name: "Bob", role: "user"}] // Find modified objects (same id, different properties)
const map2 = new Map(arr2.map(o => [o.id, o]));
const modified = arr1.filter(o => { const match = map2.get(o.id); return match && JSON.stringify(o) !== JSON.stringify(match);
});
console.log(modified); // [{id: 1, name: "Alice", role: "admin"}]

JSON.stringify comparison works for flat objects with consistent key order. For objects where key order may vary, sort the keys first or use a deep equality library.

Python — deepdiff for detailed object comparison

from deepdiff import DeepDiff arr1 = [ {"id": 1, "name": "Alice", "role": "admin"}, {"id": 2, "name": "Bob", "role": "user"}
]
arr2 = [ {"id": 1, "name": "Alice", "role": "superadmin"}, {"id": 3, "name": "Charlie", "role": "user"}
] diff = DeepDiff(arr1, arr2, verbose_level=2)
print(diff)
# {'values_changed': {
# "root[0]['role']": {'new_value': 'superadmin', 'old_value': 'admin'},
# "root[1]['id']": {'new_value': 3, 'old_value': 2},
# "root[1]['name']": {'new_value': 'Charlie', 'old_value': 'Bob'}
# }} # Compare ignoring order, matching by id field
diff_unordered = DeepDiff(arr1, arr2, group_by="id")
print(diff_unordered)

DeepDiff's group_by parameter lets you match objects by a key field (like id) instead of by position, which is essential when arrays are sorted differently.

Lodash — isEqual for deep comparison in JavaScript

import _ from 'lodash'; const arr1 = [ { id: 1, name: "Alice", settings: { theme: "dark", lang: "en" } }, { id: 2, name: "Bob", settings: { theme: "light", lang: "en" } }
];
const arr2 = [ { id: 1, name: "Alice", settings: { theme: "light", lang: "en" } }, { id: 2, name: "Bob", settings: { theme: "light", lang: "fr" } }
]; // Deep compare entire arrays
console.log(_.isEqual(arr1, arr2)); // false // Find which objects changed
arr1.forEach((obj, i) => { if (!_.isEqual(obj, arr2[i])) { // Get specific differences using reduce const changes = Object.keys(obj).reduce((acc, key) => { if (!_.isEqual(obj[key], arr2[i][key])) { acc[key] = { from: obj[key], to: arr2[i][key] }; } return acc; }, {}); console.log(`Object ${i} changed:`, changes); }
});
// Object 0 changed: { settings: { from: {theme:"dark",...}, to: {theme:"light",...} } }
// Object 1 changed: { settings: { from: {lang:"en",...}, to: {lang:"fr",...} } }

Lodash's _.isEqual handles nested objects, arrays, dates, regexes, and edge cases that JSON.stringify misses. It is the de facto standard for deep equality checks in JavaScript projects.

Object Array Comparison Gotchas

Key order affects JSON.stringify but not deep equality

JSON.stringify({a: 1, b: 2}) produces a different string than JSON.stringify({b: 2, a: 1}), even though the objects are semantically identical. If you use string serialization for comparison, sort the keys first. Better yet, use a deep equality function that ignores key order. This tool compares objects structurally, so key order does not matter.

Matching objects between arrays is ambiguous without a key

When comparing [{name: "A"}, {name: "B"}] with [{name: "B"}, {name: "A"}], should these be considered identical (same objects, different order) or completely different (every position changed)? The answer depends on your use case. Use "Ignore array order" when position does not matter, or sort both arrays by a stable key before comparing.

Undefined properties are omitted in JSON

JSON.stringify({a: 1, b: undefined}) produces {"a": 1} — the b property is silently dropped. If you are comparing objects that may have undefined values, they will appear identical to objects where those keys are simply absent. Convert undefined to null before serializing if the distinction matters.

Frequently Asked Questions

How do I compare two arrays of objects online?

Paste both arrays of JSON objects into the two panels and click Compare. The tool walks every property at every nesting level, highlighting added, removed, and modified fields. Objects are compared positionally by default (first object vs first object), or structurally when "Ignore array order" is enabled.

Does this tool compare objects by reference or by value?

By value. The tool performs deep structural comparison, recursively checking every key-value pair. Two objects are equal if and only if all their properties match, including nested objects and arrays. Reference identity is irrelevant.

Can I compare objects with different key orders?

Yes. JSON specification states that object key order is not significant, and this tool follows that principle. {"name": "Alice", "age": 30} and {"age": 30, "name": "Alice"} are treated as identical.

Is my data safe?

Yes. This tool runs entirely in your browser. Your object data — including user records, API responses, and configuration objects — is never transmitted to any server. You can safely compare sensitive production data.

How are objects matched between the two arrays?

By default, objects are matched by their index position: the first object in Array 1 is compared with the first in Array 2, and so on. If arrays have different lengths, extra objects are shown as additions or removals. Enable "Ignore array order" for similarity-based matching when objects may appear in different positions.

Can I compare arrays of objects with nested arrays inside?

Yes. The tool handles arbitrary nesting depth. Objects containing arrays of other objects, arrays of primitives, or mixed nested structures are all compared recursively. Differences at any depth level are surfaced in the output.