JSON Diff
Compare two JSON documents.
About the JSON Diff
Paste two JSON documents and see what changed between them. Both sides are parsed and reprinted with the same two-space indentation before comparison, so a minified document and a formatted one holding the same data show no differences at all. The comparison runs in your browser as you type, which makes it safe for API responses containing real records.
How to use the JSON Diff
- Paste the first document into the JSON A panel, or press Sample to load an example pair.
- Paste the second document into the JSON B panel.
- Read the diff below, with added lines in green and removed lines in red.
- Check the added and removed counts above the panels for the size of the change.
- Press Clear to empty both sides.
Frequently asked questions
- Does formatting or indentation show up as a difference?
- No. Both documents are parsed and reprinted with two-space indentation before anything is compared, so whitespace, indent width and minification are all normalised away. What remains is a difference in the data or in the order it is written.
- Why do reordered keys show as changes?
- Because the comparison is line by line and key order is preserved from the input rather than sorted. {"b":1,"a":2} and {"a":2,"b":1} hold identical data but print in different orders, so both lines are reported as changed. Sort the keys on both sides first when order is not meaningful to you.
- Why is my invalid JSON not diffed?
- Both sides must parse before anything is compared, and the parser's own message is shown inline. A trailing comma reports that a double-quoted property name was expected at a given position and line, single quotes and unquoted keys report that a property name or closing brace was expected, and an empty side reports an unexpected end of input. The exact wording comes from your browser, so Chrome, Firefox and Safari differ.
- Are numbers compared exactly?
- They are compared after a round trip through the JSON parser, which is not always exact. 1.0 is reprinted as 1, so it matches a plain 1 on the other side, and an integer beyond 2^53 loses precision in both documents alike. Compare very large identifiers as strings if the digits matter.
- What happens to duplicate keys?
- The last one wins, in both documents, because that is what the JSON parser does. A document containing a twice keeps only the final value, and the earlier one is invisible to the diff rather than reported as a difference.