{ } Format & Compare

JSON Diff — Compare Two JSON Documents

Compare two JSON documents semantically: key order ignored, big numbers exact, arrays by position or by key, ignore paths, and export an RFC 6902 JSON Patch.

Key order ignored Exact big numbers Match arrays by key RFC 6902 JSON Patch

Loading JSON Diff…

What this page sends

  • Your input: Processed in this tab and not sent to a server.
  • Page load: Loading the page requests HTML, scripts and images from ByteKiln, fonts from Google Fonts, and sends Google Analytics page views, tool-usage events and catalog interactions (tool/category IDs, result status and whether a click followed search — never your input, output or search terms). Privacy & sharing

How the JSON Diff — Compare Two JSON Documents Works

Comparing two API responses by eye, or with a line-based diff, fails on the things that don't matter and misses the ones that do. A reordered object lights up every line; a rounded 64-bit ID looks unchanged; a quantity that became the string "2" instead of the number 2 is easy to miss. This tool compares JSON structurally. Paste the original on the left and the changed version on the right, and it lists every added, removed and changed value by its JSON Pointer path, with type changes called out separately. Numbers are compared from their original text, so large integers are exact, and 1 and 1.0 are equal unless you ask otherwise. Arrays can be compared by position or matched by a key field such as id, which is what you want for lists whose order doesn't matter. Ignore noisy fields like updatedAt by name or by path pattern. The side-by-side view highlights changed lines in both documents, and the JSON Patch view gives you an RFC 6902 patch that turns the left document into the right one — tested by applying generated patches to hundreds of random documents.

Parsing

Both sides are parsed with a lossless parser that keeps each number's original text and each key's line and column. Errors are reported for the side they occur on, with the position, and the other side is left alone. Comments and trailing commas are accepted, since configuration files often have them.

Comparison

Objects are compared key by key regardless of order. Values of different types (string vs number, object vs array) are reported as type changes. Numbers are equal when they have the same decimal value, compared as exact decimal strings, never as doubles. Duplicate keys use the last value, as JSON.parse does, and a note says so.

Arrays

By position, items are compared index by index and extra items are added or removed. By key, items are matched by the chosen field's value; unmatched items on the left are removed and on the right added. If some items lack the key, that array falls back to position matching and a note says which.

JSON Patch output

The patch uses add, remove and replace operations with RFC 6901 pointers (/ and ~ in keys are escaped as ~1 and ~0). Array removals are emitted from the end so earlier indexes stay valid. Values keep their exact number text.

Limitations

  • Arrays are compared by position or by a key you choose; moved items are reported as a removal plus an addition, not as a move.
  • It compares data, not formatting: whitespace, key order and number spelling (1.0 vs 1) don't count as differences.
  • The JSON Patch has add, remove and replace only — no move, copy or test operations.
  • Both documents are held in memory; inputs over 1 MB are compared in a Web Worker, but very large files still take time.

FAQ

Short answers for the things developers usually ask before trusting a tool.

Is my JSON uploaded?

No. Both documents are parsed and compared in your browser; inputs over 1 MB are compared in a background Web Worker on your device. Nothing is sent to a server.

Why does my diff show changes when only the key order is different?

It doesn't here — JSON objects are unordered, so {"a":1,"b":2} and {"b":2,"a":1} are equal. Text diff tools show a difference because they compare characters, not structure. Use the text diff only when formatting itself matters.

How are arrays compared?

By position by default: item 0 against item 0, and so on. If the order of items isn't meaningful — a list of users or order lines — choose "Match by key" and give the ID field. Then a reordered list shows no changes, and an edited item is reported as a change to that item instead of every item after an insertion changing. The two strategies can give completely different results, which is why the active one is always shown.

Why is 9007199254740993 different from 9007199254740992?

Because they are different numbers. JavaScript's JSON.parse rounds integers above 2^53 to the nearest double, which makes those two equal — a false "no changes" for 64-bit IDs. This tool compares numbers from their original text, so they're compared exactly. By default 1 and 1.0 are equal (same value); turn on "1 and 1.0 are different" to compare the literal text.

What is a JSON Patch?

RFC 6902 describes changes to a JSON document as a list of operations like { "op": "replace", "path": "/status", "value": "paid" }. Libraries in every language apply them (fast-json-patch in JavaScript, Microsoft.AspNetCore.JsonPatch in .NET, jsonpatch in Python), and HTTP PATCH APIs often accept them with Content-Type application/json-patch+json. The generated patch always uses array positions so any implementation can apply it.

Can I ignore timestamps and generated IDs?

Yes. List key names like updatedAt, etag to ignore them anywhere, or JSON Pointer patterns like /items/*/price to ignore a specific path (* matches one level, ** any depth). Ignored paths are also left out of the JSON Patch.

Related tools

Useful follow-ups when one conversion usually turns into three more.