JSON Diff — Compare JSON Objects Online

JSON diff and JSON comparator: compare two JSONs, JSON objects, or JSON files by path. Spot adds, removes, and changes—free JSON compare in your browser. Not a line-oriented text diff.

How it works
  • + added path · − removed path · ~ changed value. Object paths use dots (user.name); arrays use indexes (items[0]). Comparison is strict (1 ≠ "1").

+ added path · − removed path · ~ changed value. Object paths use dots (user.name); arrays use indexes (items[0]). Comparison is strict (1 ≠ "1").

About JSON diff

What is a JSON diff / JSON comparator?

A JSON diff (JSON compare / JSON comparator) compares two JSON values and lists structural changes by path. Use it to compare two JSONs, JSON objects, or the contents of JSON files. This page reports added paths (+), removed paths (−), and changed values (~).

Work happens in your browser. Object paths use dots (user.name); arrays use indexes (items[0]). Comparison is strict: 1 is not "1". This is not a line-oriented text diff and not a language-specific CLI.

Compare JSON in code

JavaScript
const a = JSON.parse(left);
const b = JSON.parse(right);
function diff(x, y, path = "") {
  if (Object.is(x, y)) return [];
  if (typeof x !== "object" || !x || typeof y !== "object" || !y) return [{ path, from: x, to: y }];
  const keys = Array.from(new Set([...Object.keys(x), ...Object.keys(y)]));
  return keys.flatMap(k => diff(x[k], y[k], path ? `${path}.${k}` : k));
}
const changes = diff(a, b);
Python
import json
a = json.loads(left)
b = json.loads(right)
def diff(x, y, path=""):
    if x == y: return []
    if not isinstance(x, (dict, list)) or not isinstance(y, (dict, list)):
        return [{"path": path, "from": x, "to": y}]
    keys = set(x.keys()) | set(y.keys()) if isinstance(x, dict) else range(max(len(x), len(y)))
    res = []
    for k in keys:
        p = f"{path}.{k}" if path else str(k)
        if k not in x: res.append({"path": p, "added": y[k]})
        elif k not in y: res.append({"path": p, "removed": x[k]})
        else: res.extend(diff(x[k], y[k], p))
    return res
changes = diff(a, b)
Notation
+ user.email = "a@b.c"
- items[1] = 2
~ b 2 -> 3

JSON diff & compare FAQ

What is a JSON diff or JSON comparator?
A JSON diff (also called JSON compare or JSON comparator) compares two JSON values and lists structural changes by path. This page uses + for added paths, − for removed paths, and ~ for changed values.
How are JSON paths written?
Object keys use dots, such as user.name. Array indexes use brackets, such as items[0]. The root path is shown as (root) when the top-level value itself changes.
Is JSON comparison type-strict?
Yes. Values must match in type and content. The number 1 differs from the string "1", and object key order does not matter.
How do I compare JSON in code?
Parse both sides with JSON.parse in JavaScript or json.loads in Python, then walk objects and arrays to report path adds, removes, and changes. This page is a browser tool, not a CLI package.
Can I compare two JSON files online?
Yes. Paste the contents of each file into the two panes and click Compare. Work stays in your browser; nothing is uploaded.
How is this different from a text diff?
A text diff compares lines of text. This JSON diff compares structure by path, so key order and whitespace do not create noise.