Skip to content
PocketDesk
Your files are processed on your device, never uploaded

JSON compare

  • On device

Paste two JSON documents, open files, or drop them on the panels. Nothing leaves your device.

Original
Empty
Changed
Empty
  • F3 or n Next difference
  • ShiftF3 or p Previous difference

How to compare two JSON files

  1. Paste the original JSON into Original, or drop a .json file on the panel. Open file works too.
  2. Paste the changed version into Changed. Use Load sample to try it first.
  3. Read the summary: changed, added and removed counts. Step through them with the arrow buttons, or press F3 and Shift+F3.
  4. Click a row in the Differences table to jump to it. Copy as JSON Patch gives you the operations that turn the original into the changed file, and Download report saves the list as a Markdown file.

Both sides are shown pretty-printed with 2-space indent, so changed lines line up. Switch to Unified for a single column like a git diff.

How the comparison works

Both documents are parsed first, so spacing and line breaks never matter. The tool then walks the two trees together. Every value has a path, such as $.user.address.city or $.items[2].price, where $ is the root.

  • A key only in the second document is added. A key only in the first is removed.
  • A value present in both but different is changed, shown as old -> new.
  • If a whole object or array is added or removed, it is reported once at its root, not once per leaf.
  • If the type changes, for example a string becomes an object, that is one change at that path.

Arrays are compared position by position unless you ignore array order. In that mode equal items are matched like a multiset, and leftover objects are paired up so you still see which field inside them changed.

A worked example

First document:

{
  "user": {
    "name": "Asha",
    "city": "Pune"
  },
  "tags": ["a", "b"],
  "age": 30
}

Second document, which also adds an email key:

{
  "user": {
    "name": "Asha",
    "city": "Leeds",
    "email": "a@x.com"
  },
  "tags": ["a"],
  "age": "30"
}

With the default options the differences are:

  • + $.user.email: "a@x.com"
  • ~ $.user.city: "Pune" -> "Leeds"
  • - $.tags[1]: "b"
  • ~ $.age: 30 -> "30"

The same four rows appear in the Differences table, each with its path and the value on both sides.

Tips

  • Format messy input first with the JSON formatter, and use the JSON validator to find syntax errors and duplicate keys.
  • When two JSON files are supposed to be byte-for-byte alike, the text diff checker shows line-level changes.
  • Use Swap to flip the two documents: added and removed trade places.
  • Large integers above 9,007,199,254,740,991 lose precision in JSON parsing. Keep IDs like that as strings.
  • If a document repeats a key, the last value wins and the tool adds a note.

Your JSON is compared locally and never sent anywhere.

Questions

Does key order matter when I compare JSON?

Not by default. A JSON object is an unordered set of keys, so {"a":1,"b":2} and {"b":2,"a":1} are the same data. Turn off Ignore key order if you also want order differences reported.

How is this different from a text diff?

A text diff compares lines, so reformatting or reordering keys shows up as many changes. This tool parses both documents and compares values by path, so only real data changes are listed.

How are arrays compared?

By position, because the order of an array usually carries meaning. Turn on Ignore array order to compare them as unordered lists: equal items are matched wherever they sit, and the rest are reported as added or removed.

Is my JSON uploaded?

No. Both documents are parsed and compared in your browser, so API responses and config files stay on your device.

What if one side is not valid JSON?

The error names the side, Original or Changed, and gives the line and column of the problem. Fix it and the comparison runs again.

More developer tools