How to use the JSON diff tool
- Paste the original document into Original (A) and the newer one into Changed (B).
- Read the summary: the total number of differences, split into added, removed and changed.
- Scan the table. Each row shows the path, the kind of change and the values in A and B.
- Turn on “ignore order” if your arrays are unordered lists of simple values.
- Copy the JSON Patch if you need a machine-readable list of changes.
Swap A and B reverses the comparison, which turns additions into removals.
How the comparison works
Both documents are parsed with a strict JSON parser (comments and trailing commas are tolerated, as in the formatter). The comparison then walks both trees together:
- objects are compared key by key, so key order never matters;
- arrays are compared index by index (or as multisets when order is ignored);
- values are compared by type and value, so
1and"1"are reported as a type change, not a simple change.
Paths use JSONPath-style notation ($.users[2].email), with unusual keys quoted ($["content-type"]). The patch uses JSON Pointer (/users/2/email), where / inside a key becomes ~1 and ~ becomes ~0.
Worked examples
Example 1: a pricing change
Load the sample. The price changes from 9 to 12, a feature is renamed and another added, storage doubles, beta is removed and currency is added. Six differences appear, each with its exact path, which is easier to review than a reformatted text diff.
Example 2: API response regression
Save a known-good response as A and today’s response as B. A type change from number to string ("price": "12.00") stands out immediately. That kind of change often breaks clients even though the value looks the same.
Example 3: tags in a different order
Compare {"tags": ["red", "blue"]} with {"tags": ["blue", "red"]}. By default two changes are shown, because positions 0 and 1 differ. With ignore order on, there are no differences.
Applying the patch
The generated patch lists replacements first, then removals (array items from the highest index down so earlier positions stay valid), then additions. Libraries such as fast-json-patch (JavaScript), jsonpatch (Python) and most API frameworks can apply it. When order is ignored, changes have no single position, so no patch is offered.
Common mistakes
- Comparing formatted text. Whitespace differences aren’t data changes; compare parsed JSON instead.
- Ignoring order on arrays of objects. Order is only ignored for simple values, because object matching needs a key.
- Treating type changes as harmless.
"5"and5behave differently in code. - Huge arrays shifted by one item. An insertion at the start shows every later index as changed. Sort both arrays by a stable key first.