Data ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Data Tools

JSON Diff: Compare Two JSON Documents

Compare two JSON documents value by value: additions, removals and changes with full paths, ignoring key order and formatting, or output an RFC 6902 JSON Patch.

View all tools
ResultUpdates as you type
Differences4
Added1
Removed1
Changed2
PathChangeBefore (A)After (B)
$.ageChanged3031
$.address.cityChanged"London""Manchester"
$.tags[1]Removed"beta"
$.emailAdded"alice@example.com"

How to use JSON Diff: Compare Two JSON Documents

Paste the original JSON into A and the changed version into B, and the differences appear as you type. Choose a table of differences or a JSON Patch, and decide whether arrays are compared by index or as sets.

  1. Paste the original JSONPut the older version in Original JSON (A). Errors are reported with the line and column.
  2. Paste the changed JSONPut the newer version in Changed JSON (B). Key order and indentation do not matter.
  3. Pick the outputChoose Table of differences or JSON Patch (RFC 6902), set how arrays are compared and copy the result.

Reading the differences table

With the sample documents the counts read 4 differences: 1 added, 1 removed and 2 changed. $.age changed from 30 to 31, $.address.city from "London" to "Manchester", $.tags[1] ("beta") was removed and $.email was added. Unchanged values such as name and postcode are left out unless you tick Also list unchanged values. The comparison walks into nested objects and arrays, so only the exact paths that differ are listed, and key order and whitespace are ignored. A value that switches type, such as the number 1 becoming the string "1", is marked Type changed.

Arrays and JSON Patch output

Arrays are compared item by item by default, which suits lists where position matters. Choose Ignore order (as a set) to treat [1,2,3] and [3,2,1] as equal and list only items that are genuinely extra or missing. Switch the output to JSON Patch (RFC 6902) to get a list of operations, such as {"op": "replace", "path": "/age", "value": 31} and {"op": "remove", "path": "/tags/1"}; applying them to A in order produces B. Paths use JSON Pointer syntax, so /address/city means the city key inside address. JSON Patch output always compares arrays by index.

Accuracy and data handling

Keep the original data and spot-check fields, types and delimiters before using an important conversion. The calculation runs in your current browser; the tool code does not send the input to a processing API.

FAQ

How do I compare two JSON files?

Paste the old version into A and the new one into B. Every added, removed and changed value is listed with its path and its before and after values as you type.

Does key order count as a difference?

No. Objects with the same keys and values are equal whatever their key order and indentation. Only changed values and added or removed keys are reported.

How is a JSON diff different from a text diff?

A text diff compares lines of characters, so reformatting or reordering keys shows up as changes. A JSON diff parses both documents first and compares the data, so only real changes are listed.

Can I generate a JSON Patch?

Yes. Set Output to JSON Patch (RFC 6902) to get add, remove and replace operations that turn A into B, ready for an HTTP PATCH request or a JSON Patch library.

More Data Tools

Related tools