How to compare two JSON documents
Compare JSON files with these steps
- Paste JSON into List A and List B, or use Upload List A and Upload List B to load the documents.
- Choose By position or By key field under Array comparison.
- Enter a field name in Array key field when you use key matching.
- Choose Dot notation or JSON Pointer under Path style.
- Review the comparison after it updates, then select Export diff report or Export JSON Patch.
How JSON array matching works
By position compares index 0 with index 0, index 1 with index 1, and so on. An item inserted near the start shifts later indexes, so the result can show several changed entries for one insertion.
By key field matches object-array items by the String() value of the field entered in Array key field. The option applies only when every item in both arrays is an object with that field. If an array does not meet that condition, JSON Diff uses position matching. Duplicate key values replace earlier entries in the matching map.
List A: {"users":[{"id":1,"name":"Alice"}]}
List B: {"users":[{"id":1,"name":"Alicia"}]}
Changed: $.users[0].name
Object keys are matched by name, so changing their order does not create a difference.
JSON diff paths and export formats
Dot notation writes a path such as $.users[0].name. JSON Pointer writes the same location as /users/0/name. The selected Path style changes the path field in the exported diff report.
Export diff report creates a JSON list containing each difference's kind, selected path, JSON Pointer, and available old or new value. Export JSON Patch creates add, remove, and replace operations with JSON Pointer paths. Check array operations before applying them elsewhere, since an earlier operation can change a later index.
If an input is invalid JSON, the page shows the parser message and keeps the comparison workspace hidden. When the parser reports a position, the message includes its line and column.
When to use JSON Diff
Compare two API response fixtures after changing a field, then inspect the path in the result. You can also compare configuration exports and separate added settings from changed values.
Use key matching for arrays of records with an identifier field. Use position matching when each index represents a fixed place in the data.
JSON Diff and JSON Compare Tools
JSON Diff parses both inputs in the browser. The page-specific comparison code contains no request that sends their content to a server. To choose another comparison task, visit JSON Compare Tools.
Frequently asked questions
How do I compare two JSON documents?
Paste or upload one document into List A and the other into List B. After both inputs contain text, the comparison updates and reports added, removed, and changed values by path.
Does JSON Diff care about object key order?
No. Object keys are matched by name, so moving the keys inside an object does not create a difference.
How do I compare JSON arrays by id?
Choose By key field and enter id in Array key field. Key matching applies when every item in both arrays is an object with that field. Otherwise, the comparison uses positions.
Does Export JSON Patch use my selected path style?
No. Export JSON Patch always uses JSON Pointer paths, even when Dot notation is selected for the diff report.