JSON Editor FreeOpen the JSON editor

Docs/Compare two documents

JSON diff: compare two JSON files

This JSON diff reads the data, not the text. Spacing, indentation and the order of keys never count as a difference.

Updated

Open this page in the editor

Turn it on

  1. Put one document in the left panel and the other in the right. Open a file, paste, or drop a file on a panel.
  2. Press the Compare documents button in the header (the first button of the compare group), or press Ctrl+Alt+K.
  3. Both panels mark every difference, and the header says how many there are, as a summary of the right document compared to the left: for example +3 additions −2 deletions 3 changes. A changed value counts as one change, and the numbers always equal the marked rows. Each difference has a word and a symbol: added, removed or changed. Compare lives only in the header, so turning it on or off never moves or resizes the panels.
  4. Press Next difference or Previous difference in the header, or F7 and Shift+F7, to visit each difference in turn. The panels scroll to it and the header says where you are, for example 2 of 3.

Keys

Compare on or offCtrl+Alt+K
Next differenceF7
Previous differenceShift+F7
Copy to rightCtrl+Shift+.
Every shortcut

Compare two JSON files: an example

To run a JSON diff, put one document in each panel and press Compare documents. Both panels mark what was added, removed or changed, and the header counts it.

For example, compare {"name":"Ada","plan":"free","seats":3,"trial":true} on the left with {"seats":3.0,"name":"Ada","plan":"pro","team":"core"} on the right. The diff finds three differences: plan changed from free to pro, trial was removed and team was added. The header reads +1 addition −1 deletion 1 change.

name and seats are not marked. They sit in a different place and 3 is now written 3.0, but the data is the same, so they are not differences. A line-by-line text diff would mark them too.

Arrays work by position. ["a","b"] against ["x","a","b"] shows two changes and one addition, because each item is compared with the item in the same place.

What the marks mean

The panel that lacks a key or item shows a dashed row where it would be, such as “atmosphere · only in the left document”.

  • Added (+): only in the right document.
  • Removed (−): only in the left document.
  • Changed (~): in both, with a different value.

What counts

A difference is a key or array item that one side has and the other doesn’t, or a value that differs.

These never count: spaces and line breaks, indentation, the order of keys inside an object, and number spelling such as 1.0 and 1.

Array items are compared by position, so an item inserted at the start shifts every item after it.

In each mode

Tree mode shows the marks on rows, with a word and a symbol as well as a colour. Text mode tints the changed text. Table mode has no compare marks, so turning Compare on moves a table panel to tree mode.

On a tablet or phone (below 1024 px) both panels are always shown, one above the other; stepping scrolls each panel to the difference, and the count in the header’s second row reads in short form, such as –/3 and then 2/3.

When a JSON diff helps

  • Two API responses, before and after a change, to see which fields were added, removed or given a new value.
  • The same config file from two environments, such as staging and production, where key order and indentation often differ but should not count.
  • A test’s expected output next to its actual output, to find the one value that broke the test.
  • Two exports of the same records, to see what changed between them.

Tips for a clean JSON diff

  • Both sides must be valid JSON. If one is not, the header says which panel to fix; repair it first, see JSON formatter and JSON repair.
  • Arrays are compared by position, so sort a list of records by the same field on both sides before you compare; see Sort JSON keys and arrays.
  • To make one side match the other, press Ctrl+Shift+. to copy the whole left document to the right panel. One Undo puts the right document back.
  • For a big file, compare in tree mode and step through the differences instead of scrolling; see Open large JSON files online.
  • Comparing runs in your browser, like every tool here, so neither document is sent to a server.
PreviousFormat, compact, repairNextSort