By Vivek - October 6, 2026

Compare JSON Arrays by ID Without Reorder Noise

An API response can contain the same records in a different order. Comparing index 0 with index 0 then reports changes between different people, products or tasks. If record order has no meaning in your API contract, compare records by a unique identifier instead.

Open the JSON Diff Tool to try this example. Choose Compare arrays by: Record ID, set Record ID field to id, and clear the sample’s Ignored paths.

The example: two users, one real change

Paste this into Original JSON:

[
  { "id": 1, "name": "Ada" },
  { "id": 2, "name": "Grace" }
]

Paste this into Changed JSON:

[
  { "id": 2, "name": "Grace Hopper" },
  { "id": 1, "name": "Ada" }
]

Click Compare JSON. With ID matching, the result is 0 added, 0 removed and 1 changed. Grace’s name changed; Ada’s record moved but its values stayed the same.

Switch to Array index and compare again. You get four changed fields because both IDs and both names differ at the same positions. Index comparison is correct when position matters, such as a ranked leaderboard. It is noisy when the array is just an unordered collection of records.

Keep both locations when records move

Grace’s original name is at $[1].name; her new name is at $[0].name. The result shows both locations rather than inventing an ID selector that looks like a JSONPath.

Download saves a JSON report containing the rules, summary and changed entries. For this change, the useful fields are:

{
  "type": "changed",
  "path": "$[0].name",
  "before": "Grace",
  "after": "Grace Hopper",
  "beforePath": "$[1].name",
  "afterPath": "$[0].name"
}

Use Show unchanged for context. If you edit either document or a comparison rule, compare again before exporting. The previous result becomes out of date.

Choose an identifier you can trust

Every record in an object array needs the selected field, and its value must be a unique string or safe integer within that array. Duplicate IDs cause an error because the tool cannot determine which record matches which. A name is usually a poor identifier if two people can share it.

The same field applies to nested object arrays. A response with users identified by id and line items identified by sku needs those sections compared separately. Primitive arrays such as ["admin", "editor"] still compare by index.

Numeric 1 and string "1" are different identifiers. Large integer IDs should be quoted strings: ordinary JavaScript JSON parsing can lose numeric precision, as described in the MDN JSON.parse reference. This tool rejects unsafe integer values rather than treating rounded IDs as equal. Decimal values still use JavaScript number precision.

Handle timestamps separately

ID matching removes record-order noise. It does not suppress changed timestamps, request identifiers or other volatile values. For that, follow Compare API responses while ignoring timestamps.

If you only need one part of a larger response, use the JSONPath Tester to extract that section, then compare it. Reports stop at 1,000 rows and mark themselves as partial; a partial report does not establish equality.

For a step-by-step extraction example, follow Filter a nested API response with JSONPath. Browse all five workflows in the JSON tools and API debugging hub.