plain/devtools home

JSON diff

Paste two JSON documents and get a list of what changed, by path. Key order does not matter, and nothing leaves this tab.

tool 14 of 21 []
all shortcuts ?

json-diffsamplesCtrl↵ run · s sample · c copy

never leaves your browser

How to use it

  1. Paste the original document on the left and the changed one on the right. Both must be valid JSON; if one is not, the message says which side and where the parser stopped.
  2. Every difference is listed by its path, such as $.user.roles[1]. Lines starting with - are the old value and lines starting with + are the new one.
  3. Objects are compared by key, so reordering keys is not a change. Arrays are compared position by position, so inserting an item near the top of an array shows every later item as changed.
  4. Copy the plain-text report to paste into a pull request, a ticket or a changelog.

What counts as a difference

JSON has six value types: object, array, string, number, boolean and null. This tool reports a path as changed when the type differs (1 versus "1", null versus an empty object) or when a string, number or boolean differs. It reports a path as added or removed when a key or array position exists on only one side.

Object member order carries no meaning in JSON. RFC 8259 describes an object as an unordered collection of name and value pairs, so a diff that flags reordered keys is noise. This tool sorts that out by comparing by key.

Arrays are ordered, and there is no key to match items on, so they are compared by index. If your arrays are really sets (tags, IDs), sort them before you compare, or expect a shifted array to show many changes.

How each case is reported

SituationReported asExample path
Key only on the rightAdded (+)$.owner
Key only on the leftRemoved (-)$.legacy_id
Same key, different scalarChanged (- then +)$.port
Same key, different typeChanged (- then +)$.limit (1 versus "1")
Array longer on the rightAdded at each new index$.tags[2]
Array shorter on the rightRemoved at each missing index$.tags[1]
Same members, different key orderNot a difference(none)
Key with a dot or space in its nameBracket form$["a.b"]

Numbers are compared as parsed by the browser (IEEE 754 doubles). Integers beyond 2^53 may compare equal when their digits differ.

Examples

Select an example to load it into the tool.

  • Config change{"name":"api","port":8080,"debug":true,"tags":["web","v1"]}
  • Key order only{"a":1,"b":{"x":1,"y":2}}

Frequently asked questions

Does it ignore key order?

Yes. Objects are compared by key. Arrays are ordered, so a different item order in an array is a difference.

Why does inserting one array item show many changes?

Arrays are compared by position. An item added at the start shifts every later item by one index, so each later position differs. Sort or key the array first if order is not meaningful.

Is this the same as JSON Patch (RFC 6902)?

No. The report is meant for people to read. JSON Patch is a machine format with operations such as add, remove and replace. The paths here use a JSONPath-like notation rather than JSON Pointer.

Is my JSON uploaded?

No. Both documents are parsed and compared in this tab. The test suite fails the build if this tool contains a network call.

How large a document can it compare?

It runs in the page, so the limit is your browser memory. A few megabytes compare instantly; very large files will slow the tab.

Sources

Related tools

esc
↑↓ move↵ open? all shortcuts

Keyboard shortcuts

Cmd or Ctrl shortcuts always work.
Everywhere
Everywhere
Open the command palette
CtrlK
Open the palette (outside a text field)
/
Show these shortcuts
?
Toggle light and dark theme
t
Go home
gh
Go to all tools
gt
On a tool page
On a tool page
Run the main action
Ctrl↵
Copy the output
c
Load the next sample
s
Focus the input
i
Leave a text field
Esc
Previous or next tool
[]
In the palette
In the palette
Move the selection
↑↓
Open the selected item
↵
Close
Esc