About Online JSON Compare
JSON Compare finds the differences between two JSON documents. Use it to see what changed between two API responses, a configuration file before and after an edit, or the expected and actual output of a test.
- Compare two JSON documents side by side
- Highlight added, removed and changed lines
- Highlight the changed characters inside a line
- Ignore key order, spaces and line breaks
- Compare arrays, numbers and strings as typed
- Mark JSON syntax errors as you type
- Show the first parse error with its line number
- Free to use
What is a JSON diff?
A JSON diff shows what changed between two JSON documents: keys added or removed, values changed, items added to or removed from an array. A plain text diff compares lines as written, so a key moved to another place or a different indentation shows up as a change. A JSON diff compares the data, and the same object written two ways has no differences.
How to compare two JSON files online?
Paste the contents of the original file into the Original JSON field and the contents of the modified file into the Modified JSON field. The differences appear below, the original on the left and the modified JSON on the right. If either document is not valid JSON, you get the parse error and the line it is on instead; the JSON Fixer repairs it.
How does JSON Compare work?
Both documents are checked with the same JSON parser as the JSON Formatter. Then each is formatted with 4-space indentation, and the keys of every object are sorted. The two copies are compared line by line, and inside each changed line, character by character. Nothing is sent to a server: the comparison runs in your browser.
JSON Compare Example
Below are two versions of an API response. In the second, the keys come in a different order, the role has changed, a tag is removed and lastLogin is added.
JSON Compare shows three differences: role changed from "editor" to "admin", "json" removed from tags, and lastLogin added. The keys that moved show no difference.
What counts as a difference?
JSON Compare ignores the order of keys, not the order of array items.
- Key order inside an object does not count: {"a": 1, "b": 2} and {"b": 2, "a": 1} are equal.
- Spaces, tabs and line breaks between values do not count.
- The order of array items counts: [1, 2] and [2, 1] differ.
- Numbers are compared as typed: 18.00 and 18 differ.
- Strings are compared as typed: "é" and "é" differ.
How to compare JSON in Python and JavaScript?
In Python, json.loads(a) == json.loads(b) returns True when both documents hold the same data: dictionaries are equal whatever their key order, lists only in the same order, and 18.00 equals 18. In Node.js, util.isDeepStrictEqual(JSON.parse(a), JSON.parse(b)) works the same way. Comparing JSON.stringify output does not: it keeps key order, so reordered keys come out different. All three return true or false; to see which values differ, compare the documents on this page.
Online JSON Formatter
To format one JSON document with 2 spaces, 4 spaces or tabs and view it as a collapsible tree, use the JSON Formatter.
Online XML Compare
To see what changed between two SOAP responses or two versions of an XML file, use the XML Compare. It ignores indentation and line breaks.