Skip to content
JSON Tidy

Compare two JSON documents

Paste two versions of an API response, config file, or export to see exactly what changed. It runs in your browser, so neither document is uploaded.

Original

Updated

How the comparison works

The tool compares values, not lines of text. Key order and spacing are ignored, so {"a":1,"b":2} and {"b":2,"a":1} count as the same. Arrays are compared position by position, which means inserting an item near the start of a list shows up as a change to every item after it.

Numbers are compared as written, so 1 and 1.0 are reported as different. Strings are compared after escapes are decoded, so "\u0061" and "a" match. If either document repeats a key inside the same object, you’ll get an error instead of a result, because there’s no way to know which value was meant.

Each difference comes with a path like /users/0/name, meaning the name of the first user. That’s JSON Pointer notation. Inside a key, ~1 stands for a slash and ~0 for a tilde. A value that’s missing on one side is reported differently from one that’s null.

If one of the documents won’t parse, fix it first in the JSON validator. If objects and arrays are new to you, start with What is JSON?

Comparing two API responses from a site you’re signed in to? The JSON Tidy browser extension can send a response and the one before it straight here.

JSON diff on the command line, and in Python or Node.js

If you have jq installed, you can get a rough JSON diff in the terminal by sorting the keys of both files and running an ordinary diff on the result:

diff <(jq -S . old.json) <(jq -S . new.json)

For a file where age went from 30 to 31 and a second role was added, that prints:

2c2
<   "age": 30,
---
>   "age": 31,
5c5,6
<     "editor"
---
>     "editor",
>     "admin"

But diff still compares lines, not values. "editor" is reported as changed just because a comma now follows it, and in a bigger file you’d have to work out for yourself which object each line belongs to. The tool above compares the parsed values instead and gives you the path to every change.

If all you need is a yes or no, say in a test, parse both files and compare the results:

# Python
json.load(open("old.json")) == json.load(open("new.json"))

// Node.js
import { isDeepStrictEqual } from "node:util";
isDeepStrictEqual(JSON.parse(oldText), JSON.parse(newText));

Neither one cares about key order. Unlike the tool above, both also treat 1 and 1.0 as the same value.