Skip to content
Deftkit

JSON Diff — Compare Two JSON Files

Compare two JSON objects and see added, removed, and changed values. Free, fast, and 100% client-side — your data never leaves your browser.

Paste two JSON objects — the diff updates as you type. Arrays compare index-by-index, objects compare by key.

3 changes:+ 1 added~ 2 changed
~age: 3031
~roles[1]: "editor""viewer"
+team: "platform"

Why compare JSON?

Comparing two JSON objects is one of the most common chores in modern development and ops work. You have an API response from yesterday and one from today. You have a configuration file before and after a deploy. You have a database dump and a fixture file that is supposed to match. You have the response from a production endpoint and the response from a staging endpoint. The question is always the same: what changed?

This tool shows you exactly that — a compact list of every added, removed, and changed value between two JSON documents. Paste the old version on the left, the new version on the right, and the diff updates as you type. No files, no upload, no server round-trip.

How the diff works

The diff is computed structurally by walking both JSON trees in parallel. At every node the algorithm decides what kind of change (if any) happened:

  • Both objects: the algorithm walks every key in the union of the two. Keys present only in the left are reported as removed; keys present only in the right are added; keys in both are compared recursively.
  • Both arrays: compared index-by-index. If the arrays have different lengths, the extra entries on the longer side are reported as added/removed at their index. No move detection, no longest-common-subsequence — just a straight positional walk.
  • Mixed or primitive mismatch: reported as a changed entry at that path, with both the old and the new value.
  • Strictly equal values: no entry produced. Only actual differences appear in the output.

Path notation uses dot-paths for object keys (user.address.city) and bracket notation for array indices (users[2].email). Keys that aren't clean JavaScript identifiers are quoted inside brackets (config["weird-key"]).

Example

Given these two JSON values:

Left:                              Right:
{                                  {
  "name": "Alice",                   "name": "Alice",
  "age": 30,                         "age": 31,
  "roles": ["admin", "editor"],      "roles": ["admin", "viewer"],
  "email": "alice@example.com"       "email": "alice@example.com",
}                                    "team": "platform"
                                   }

The diff reports:

~ age: 30 → 31
~ roles[1]: "editor" → "viewer"
+ team: "platform"

Three changes: age went from 30 to 31, the second role was replaced (index-by-index comparison sees this as a single position changing), and a new top-level key was added. The email key is present and equal in both, so it does not appear in the output.

What this tool is — and isn't — good at

The structural index-by-index approach is the right choice for most common tasks: comparing API responses, checking a config migration, verifying a fixture, spotting a typo in a copied object. It's fast, predictable, and produces a small diff when the change is small.

It is not the right choice when:

  • You need to compare two lists where items have been reorderedbut not changed. A simple positional walk reports every position as changed; a smarter algorithm (like Myers diff or a key-based list comparison) would report zero changes. Future versions of this tool may add a "compare by key" mode for arrays of objects.
  • You need to see an exact textual diff with context lines and whitespace preservation. That's a line-based diff (what git diff does) and a different tool category. If you want text diff, format both JSON values the same way and paste them into a text diff tool.

How to use this JSON diff

  1. Paste the original JSON into the Left pane
  2. Paste the new JSON into the Right pane
  3. The diff updates instantly below the inputs. A summary line shows how many values were added, removed, or changed.
  4. Click Copy diff to put a plain-text version on your clipboard (formatted as + path: value, - path: value, ~ path: old → new) — handy for pasting into a pull request comment or a chat message
  5. Click Swap to flip the two sides — useful for seeing the diff from the other direction
  6. Click Sample to load a small example if you want to see the tool in action before pasting your own data

Privacy and security

Your JSON never leaves your browser. All parsing and comparison happens locally using JSON.parse and a small inline diff walker. There is no upload, no server-side processing, no log, no copy stored anywhere. You can safely paste API responses containing production tokens, database rows with customer information, or any other sensitive payload — none of it touches a server.

Frequently asked questions

Why does it say every array position changed when I only reordered one item?

Because the algorithm compares arrays index-by-index. If you reorder ["a", "b", "c"] to ["b", "a", "c"], positions 0 and 1 both changed (even though nothing was added or removed). This is the right behavior for some use cases (position matters, e.g. SQL result sets) and the wrong behavior for others (position doesn't matter, e.g. a set of tags). Future versions may add a toggle for key-based or order-insensitive array comparison.

Can I diff JSON5, JSONC, or JSON with comments?

Not directly — this tool uses the browser's built-in JSON.parse, which is strict JSON only. If your input has comments or trailing commas, strip them first (or use the JSON Formatter to validate and clean each side before pasting here).

What if the two JSON objects have keys in a different order?

Key order does not matter for object comparisons — the algorithm walks by key name, not by position. So {"a":1,"b":2} and {"b":2,"a":1} produce zero differences.

How large a JSON can I compare?

Browser memory and the textarea rendering impose practical limits. Documents up to a few megabytes compare instantly on a modern machine. Much larger documents may lag the UI; if that happens, consider diffing just the relevant subsection. The algorithm itself is O(n) in the total number of nodes, so it scales well once the input is parsed.

Does this tool send my data anywhere?

No. Everything runs in your browser — no upload, no analytics on the JSON content itself, no cookie tied to your input. The tool works in incognito mode and works offline once the page has loaded.

What's the difference between this and a text diff tool?

A text diff (like git diff or online unified-diff tools) compares the raw characters of two strings line by line. It will report whitespace changes, key reordering, and formatting differences as diffs — which is often noise for JSON. This tool is structural: it parses both sides and only reports semantic differences. Two JSON documents with the same keys and values but different formatting will show zero diffs here, while a text diff might show dozens of line changes.