Online JSON Diff Tool

Compare two JSON documents as structures, not as lines. Every difference is shown with its key path, array items can be matched on an identity field, and the result downloads as an RFC 6902 JSON Patch. What you paste never leaves your browser.

First document

Second document

Array matching
0 Added
0 Removed
0 Value changed
0 Type changed
0 Moved
0 Unchanged

Difference tree

Click the key path at the end of a row to copy that path to the clipboard.

JSON Patch (RFC 6902)

[]

How do you compare JSON?

  1. Put the two documents side by side

    Paste the JSON documents you want to compare into the left and the right box. You can also drop the files straight onto them; neither one is uploaded to a server.

  2. Choose how arrays are matched

    Match by position for arrays whose order means something. For lists of records switch to key matching: items are paired on an identity field such as id, and a change of position stops counting as a difference.

  3. Read the difference in the tree

    Added, removed, edited and retyped nodes each get a colour of their own. The key path at the end of a row copies with one click.

  4. Take the result as a JSON Patch

    Copy or download the RFC 6902 output. The tool also applies the patch to the first document and confirms that the result is the second one.

How is this different from comparing text?

A text comparison looks at lines. If a tool rewrote the same JSON document with the keys in another order, or changed the indentation from two spaces to four, a line diff marks half the file as changed even though not one value did.

This tool parses first and compares the structure afterwards. An object is a set of keys, so their order is not a difference. An array is a sequence of items, so a change of position is its own kind of difference — and items can be matched on an identity field instead. Every row you end up looking at is a value that really changed, and where it lives is written as a key path, not as a line number.

When what you are comparing is not JSON, a line-based comparison is still the right tool: the text and code compare page works at line, word and character level and produces a unified diff.

Text and Code Compare

Line, word and character level diff, with unified diff output.

Arrays: by position or by key?

Arrays are the hard part of comparing JSON. Fetch a list from an API twice and the records may be the same while their order is not. A tool that compares by position reports the whole list as changed even though no record is.

Matching What it does When to use it
By position Pairs items by their position, finding what was inserted or dropped so the rest does not shift out of line. Arrays whose order means something: steps, priority lists, time series.
By key Pairs objects on an identity field. A record pulled to the top of the list counts as moved, not as one deletion plus one addition. Lists of records: users, products, events. Leave the field empty and the tool tries id, uuid, key and their like on its own.
Ignore order Matches identical items wherever they sit and compares the rest in order. Arrays whose order is incidental: tags, permissions, sets.

What is a JSON Patch, and what is it for?

A JSON Patch is the format defined by RFC 6902: a list of operations that turns one document into another. Being JSON itself, it travels in the body of a request, goes into a log, or lives in version history. Each operation addresses its target with a JSON Pointer.

Once the differences are found, this tool writes the patch, then applies what it wrote to the first document and checks whether the result is the second one. The verdict sits above the panel: the patch is tested rather than merely claimed to be right.

Operation What it means
addAdds a new key or array item.
removeDeletes an existing key or array item.
replaceReplaces an existing value with a new one.
moveTakes a value from where it is and puts it somewhere else; this is how a reordered array is written.

Five things people most often get wrong when comparing JSON

Value pair What is actually true
1 / 1.0 To JSON these are the same number; the difference is in how it was written, not in the value. The tool reports nothing.
1 / "1" One is a number and the other is a string, which is a type change and gets its own colour. Turn on type tolerance if the distinction does not matter to you.
null / a missing key A key set to null is not the same as a key that is absent. One is a deletion, the other a change of value, and the tool keeps them apart.
{} / [] An empty object and an empty array are different types. Most text comparisons show this as a one-character difference; here it comes out as a type change.
A repeated key A key appearing twice in the same object is valid JSON, and readers keep the last one. The tool accepts it but does not swallow it quietly: it names the line the repetition sits on.

Key features

Structural comparison

Values are compared, not lines. A document that was reformatted, or whose keys were written in another order, produces no differences at all.

Match arrays by identity

Pair lists of records on a field such as id: a record whose position changed reads as moved instead of as a deletion beside an addition.

A key path for every difference

Every row carries its own path. One click copies it, ready to paste into code or into a bug report.

A patch that tests itself

The RFC 6902 output is generated, applied to the first document, and checked against the second. You see the verdict on screen.

Errors come with a place

Invalid JSON is reported with a line and a column, and repeated keys are listed as warnings of their own.

Your document stays with you

Parsing, comparison and patch generation all run in your browser. The configuration or API response you paste is never sent anywhere.

FAQ

Paste one document into each box, or drop the files onto them. The comparison runs as you type: the diff tree marks every added, removed, edited and retyped node in its own colour, each with its key path. Nothing leaves your browser — the documents are never uploaded.

A text comparison looks at lines. Reformatting a document, changing its indentation or writing its keys in another order produces hundreds of line differences even though no value changed. A structural comparison parses first: an object is a set of keys, an array is a sequence of items. What you get back is only the values that actually differ.

No. In the JSON standard the keys of an object are unordered, so {"a":1,"b":2} and {"b":2,"a":1} are the same object. The tool reports no difference between them, but it does tell you when the only thing that changed was the order — useful confirmation that a rewritten file is otherwise untouched.

By default yes, but insertions and deletions are detected, so adding one record at the top does not make everything below it look changed. For lists of records switch to key matching: items are paired on an identity field such as id, uuid or key. A record pulled to the top then reads as moved rather than as a deletion plus an addition. You can also type the field name yourself.

Because in JSON one is a number and the other is a string, and to most code consuming the document that is a real difference: a field that returned a number in one version of an API and returns text in the next is exactly what a comparison should surface. If the distinction does not matter to you, turn on the number-and-text option — the tool then also tells you that the patch no longer reproduces the target document exactly.

No, and the tool keeps them apart. A key whose value is null exists and holds an empty value; a key that is absent is not defined at all. The generated JSON Patch preserves the distinction too: one produces a replace, the other a remove or an add.

A JSON Patch is a list of operations that turns one document into another, and it is itself JSON. You can send it in the body of an HTTP request, write it to an audit log, or keep it in version history as the change between two configuration revisions. The tool writes the patch, then applies it to the first document and checks whether the result is the second one, showing the verdict on screen.

The standard does not forbid it; most readers keep the last value and some keep the first, so the same document can quietly be read two different ways. The tool accepts such a document but does not swallow the repetition: it warns you, naming the key and the line it repeats on.

The comparison stops and the reason appears under that box with a line and column number: an unclosed bracket, a trailing comma, single quotes, an unquoted key or a malformed number are each named separately. Instead of the browser's own wording you get a sentence saying what was expected and where.

No. Parsing, comparing and patch generation all run in your browser; the documents are neither uploaded nor stored. That makes the tool safe for production configuration, API responses holding customer data and personal records.

Easily get your dream job!

Sign Up
Sign up Easily
Show your programming skills
Evaluate the offers