JSON Diff — Compare JSON Online
JSON Diff
Paste two JSON documents, one on each side, and JSON Diff lists what was added, removed, changed or moved between them. Differences appear in a split or unified view, in a tree, and in a Report tab. The result can be exported as a JSON Patch or as a Markdown or HTML report. The comparison runs in your browser.
How this tool handles it
- Parsing. Each side is read with
JSON.parse. A parse error reports the line and column on that side, and no diff is shown until the input is fixed. The Repair Left and Repair Right buttons runjsonrepairon that side when you press them. - Objects. Keys are compared one by one. A key present on only one side is reported as added or removed.
- Arrays. In strict mode, the default, items are compared by position. In Ignore Array Order mode, each item is matched to an identical item on the other side, or to a similar one, so reordered items are not reported as changes.
- Types. A number and a string with the same text are different.
129.5and"129.50"are reported as a type change.nulland a missing key are different too. - Options. Ignore Case and Ignore String Trim affect how strings are compared. Match objects by key pairs array items by one property, such as
id. Report moved items shows reordered items as moved. Ignore paths skips a path such as$.updatedAt, a wildcard such as$.items[*].id, or a bare key such asupdatedAtat any depth. Sort Keys sorts object keys before the diff is built. - Size. When the two inputs together exceed 200,000 characters, the diff runs in a web worker so the page stays responsive. An array with more than 50,000 items is compared as one entry, which is marked modified when it differs, with no item-level detail.
- Export. JSON Patch (RFC 6902) can be copied or downloaded, and the Apply JSON Patch dialog applies a patch to the left document. Markdown and HTML reports can be copied or downloaded.
Example
Left:
{"id": 1042, "status": "pending", "total": 129.5, "tags": ["new", "gift"], "note": "leave at door"}Right:
{"id": 1042, "status": "shipped", "total": "129.50", "tags": ["gift", "new"], "carrier": "UPS"}The Markdown report for the default settings contains this table:
| Path | Change | Left | Right |
|---|---|---|---|
| $.status | modified | "pending" | "shipped" |
| $.total | type changed | 129.5 | "129.50" |
| $.tags[0] | modified | "new" | "gift" |
| $.tags[1] | modified | "gift" | "new" |
| $.note | removed | "leave at door" | |
| $.carrier | added | "UPS" |
The statistics above the table read 1 added, 1 removed, 4 modified and 1 equal. Switch on Ignore Array Order and the two tags rows disappear.
Gotchas
Strict arrays compare by position
Left [{"sku": "A"}, {"sku": "B"}], right [{"sku": "Z"}, {"sku": "A"}, {"sku": "B"}]. In strict mode the first two items are reported as modified and the third as added. With Ignore Array Order on, the result is one added item and two equal items.
A type change is a difference
"total": 129.5 on the left and "total": "129.50" on the right are reported as a type change, even though they hold the same value. Ignore String Trim and Ignore Case do not change this. Convert one side so both use the same type.
A null is not a missing key
Left {"a": null}, right {}. The key a is reported as removed, because the right side does not have it. Treat null and a missing key as separate values when you compare.
A changed array in a JSON Patch is replaced whole in smart mode
In strict mode the patch has one operation per changed item, such as {"op": "replace", "path": "/tags/0", "value": "gift"}. In Ignore Array Order mode, a changed array is replaced with the full right-hand array, for example {"op": "replace", "path": "/items", "value": [...]}. The patch is correct but not minimal.
FAQ
How do I compare two JSON files?
Paste each document into its side, or use Import Left JSON and Import Right JSON to read a file into one side.
Can it compare large files?
Yes, with two limits. Inputs above 200,000 characters combined run in a worker. An array with more than 50,000 items is compared as a single entry.
Does it work with malformed JSON?
Not until the input is fixed. The parse error shows the line and column. Repair Left or Repair Right runs jsonrepair on that side, which handles the same common errors as JSON Fix.
Is my data uploaded to a server?
No. The comparison runs in the browser, and the page makes no network request with the input. Copy Share Link stores both documents in the URL, so anyone with that link can read them.
Can I export the result?
Yes. The result can be exported as a JSON Patch, an HTML report or a Markdown report.