JSON Diff Checker
Compare two JSON documents and see every added, removed and changed value with its path, ignoring key order and formatting, or copy the differences as a JSON Patch. Runs in your browser.
Input
Output
Readme
What does the JSON Diff Checker compare?
It compares two JSON documents by what they contain, not by how they are written. Every value that was added, removed or changed is listed with its path, and marked in both editors, so you can see at a glance how an API response, a config file or a data export changed between two versions.
How to use it
- Paste or type the original JSON in the first box and the changed JSON in the second.
- The differences appear right away, counted by kind and listed in order.
- Click a difference to scroll both editors to it, or click a mark in an editor to find its row in the list.
- Open the JSON Patch tab to copy or download the same differences as JSON Patch operations.
If one of the documents isn't valid JSON, the tool says which one and gives the line and column of the problem, marked in that editor.
What counts as a difference
- Key order, indentation, spaces and line breaks don't count:
{"a": 1, "b": 2}and{"b": 2, "a": 1}are identical. - Types count: the number
1and the string"1"are different values. Numbers are compared by value, so1.0and1are the same. - In arrays, order counts. Items that are objects with an
idor_idfield are matched by it, so a reordered list shows the items that moved instead of a change in every row. - Other array items are matched by value, so a value inserted in the middle of a list is one addition. Objects without an id are compared by their position in the array.
- Long strings are compared as whole values: a changed string shows its old and new text.
Reading the results
- Added values are shown in green, removed ones in red, and changed ones as the old value followed by the new one. A moved array item shows where it was and where it is now.
- Paths are written as JSONPath, starting from
$, the whole document:$.items[2].nameis thenameof the third item initems. Keys with spaces or other characters are written in brackets, like$["first name"]. - A removed value's path is its place in the original document; an added or changed value's path is its place in the changed one.
JSON Patch
The JSON Patch tab writes the differences as operations of the JSON Patch standard (RFC 6902): add, remove, replace and move, each with a path in JSON Pointer form such as /items/0/price. Applied in order to the original document, they give the changed document, and libraries in most programming languages can apply them for you. Download them as patch.json.
How it works
The tool parses both documents in your browser and compares them with the jsondiffpatch library, which matches array items with a longest common subsequence algorithm and detects items that moved. Nothing you paste is uploaded anywhere.
Examples
{"price": 3}and{"price": 3.25}: changed$.price, 3 to 3.25["organic", "local"]and["organic", "vegan", "local"]: added$[1], "vegan"{"hours": {"sat": "8-14"}}and{"hours": {}}: removed$.hours.sat- A list of products with ids, reordered and with one price changed: one moved item and one changed price, not a change in every row
Features
- Compares JSON by content, ignoring key order and formatting
- Added, removed, changed and moved values with their paths
- Differences marked in both editors, with click to scroll
- Array items matched by
idor_id - JSON Patch (RFC 6902) output to copy or download
- Line and column of syntax errors
- Runs in your browser