JSON Diff Online
Compare two JSON files by their data. Reordered keys are not changes, and type changes are called out.
Original
Modified
Why a JSON diff is not a text diff
JSON objects are unordered. {"a":1,"b":2} and {"b":2,"a":1} are the same document, but a text diff will paint both lines as changed. Run an API response through a formatter, or a serializer that emits keys in a different order, and a plain diff becomes unreadable: every line moved, nothing actually different.
This tool parses both sides first, sorts keys at every level, then compares. What you get back is the list of JSON paths that actually differ.
Types are reported separately
{"id": 1} and {"id": "1"} differ by one character as text, and by something that will break a strict consumer as data. Type changes (number to string, object to array, a value becoming null) are counted and labelled apart from ordinary value changes.
Arrays keep their order
Array position is meaningful in JSON, so arrays are compared element by element and reordering one is a real difference. Only object keys are treated as unordered.
If one side will not parse
Both documents have to parse before they can be compared. If a backend rejected one of them first, these pages explain its error:
- Expecting value: line 1 column 1 (char 0)
- Expecting property name enclosed in double quotes
- Extra data: line 1 column N (char N)
- Expecting ',' delimiter
- Unrecognized token: was expecting a value
- Unexpected character ('}' (code 125))
- HttpMessageNotReadableException: JSON parse error
- Cannot construct instance of X (no Creators, like default constructor, exist)
- Unrecognized field "X" (class Y), not marked as ignorable
- No content to map due to end-of-input
- json_decode() returns null
- invalid character '<' looking for beginning of value
Nothing leaves your browser
Parsing and comparison happen on your machine. No upload, no account, and no size limit imposed by a server: which means you can compare files you would not be willing to paste into a hosted tool.