JSON Diff Online

Compare JSON objects and find differences instantly.

ORIGINAL1 lines
MODIFIED1 lines

When a JSON diff is the right tool

JSON carries a large share of everyday engineering state: API fixtures, package manifests, editor settings, exported app state, and the payload a colleague pasted into a chat. Two of those documents can look almost the same in an editor and still disagree in a way that breaks a client. A JSON diff is for that moment. You put the previous version on the left, the new version on the right, and read every added, removed, or replaced line instead of scanning both files by eye.

This page is aimed at that comparison, not at general-purpose editing. If you only need to tidy or compress a single document, use the JSON Formatter. If you need to know whether a document matches a schema, use a validator. If the file is actually YAML, use YAML Diff rather than pasting it here, because this tool requires strict JSON. If the text already lives in Git, a browser diff is still useful for a throwaway paste, but git diff is the better tool once the change belongs in a repository.

Use cases

Checking an API fixture before a client ships

A backend change often arrives as one JSON fixture that mixes several decisions: a renamed field, a new nested object, a status string that used to be a number. Pasting the old and new payloads makes each decision visible as its own marked line, so you can ask “did we mean to add this key?” instead of rereading a 200-line blob.

Reviewing package.json, tsconfig, or exported settings

Manifests and editor configs are easy to misread in a pull request because most of the file did not change. A one-value edit — a dependency version, a license field, a compiler flag — is easier to trust when it is the only green or red line on the page. Load Sample on this page uses a small package-style object if you want to see that kind of change first.

Comparing a minified payload with a formatted copy

Logs and some APIs emit JSON on a single line. After this tool parses and re-indents both sides, a minified document and a neatly formatted copy of the same value usually line up, and only the real edits remain highlighted. That is the main reason this page exists instead of a generic text diff.

How the comparison works

When you choose Compare, each pane is parsed as JSON. If either side fails, the page reports an invalid JSON error for the left or the right and does not produce a diff. If both sides parse, they are written back with two-space indentation, then compared line by line. Identical lines stay across from each other. A line that exists only on the left is marked as removed. A line that exists only on the right is marked as added. You can switch between split and unified views, and copy the unified result if you need a record.

The pretty-print step is ordinary JSON.stringify, not a semantic tree matcher. It normalizes whitespace and wrapping, and it will collapse a duplicate key to the last value the parser kept. It does not sort keys, and it does not treat two objects as equal just because they contain the same properties in a different order.

Example — a value change and a new property
{
  "name": "diffcheck",
  "version": "1.0.0",
  "author": "Alice"
}

{
  "name": "diffcheck",
  "version": "1.2.0",
  "author": "Alice",
  "license": "MIT"
}

After formatting, the name and author lines stay unchanged. The version line appears as a removal of 1.0.0 and an addition of 1.2.0. The new license property appears only on the right. That is the distinction you want when writing a changelog: an edited version is not the same kind of change as a new field.

Example — equivalent JSON that a line diff still marks
{
  "enabled": true,
  "name": "queue"
}

{
  "name": "queue",
  "enabled": true
}

These two objects have the same keys and values. In JSON they are equivalent, but because the formatter keeps each side's key order, a line diff reports a change. If that is the only difference you see, the documents are probably the same for a parser. Reorder the keys if you want the lines to match, or ignore those lines.

What this tool does not do

It does not validate a JSON Schema, produce a JSON Patch, ignore key order, or highlight syntax by type. It will not accept comments or trailing commas. Numbers may be rewritten in a canonical form (1.0 becoming 1, for example), which can show up as a one-line change even when the numeric value is the same. Nothing is sent to a server. Very large documents can still be pasted, but they may make the tab feel slow.

How to use JSON Diff

  1. Paste the older or expected JSON into the original pane.
  2. Paste the newer JSON into the modified pane.
  3. Choose Compare. If a side is invalid, fix the syntax reported for that pane and compare again.
  4. Switch between split and unified views, and copy the result if you need to keep a record. Use Swap if the sides are reversed, Clear when you are finished, or Load Sample to try a small example first.

If you later need to turn the same data into YAML, the JSON to YAML converter can do that in the browser. To check a document against a schema rather than against another copy, use the JSON Schema Validator.

Frequently asked questions

Does JSON Diff pretty-print before it compares?

Yes. Each side is parsed with JSON.parse and rewritten with JSON.stringify using two-space indentation. Whitespace and wrapping differences usually disappear. The comparison itself is still a line diff of those rewritten documents, not a tree walk that matches keys independently of line breaks.

If two objects have the same keys in a different order, will they look identical?

Not in this tool. Key order is not significant in JSON, but the formatter preserves the order the keys had in each input, then the line diff compares those lines. If the keys swap places, those lines are marked as changed. Reorder the keys to match, or treat that difference as formatting rather than a real edit.

Can I compare JSON arrays, numbers, or a single string?

Yes. Any value that JSON.parse accepts can be compared: objects, arrays, strings, numbers, booleans, or null. Each side must be valid JSON on its own. An array is pretty-printed with one element per line, so inserting an item in the middle will also shift the lines below it.

Does it accept comments, trailing commas, or JSON5?

No. The parser is standard JSON. Comments, trailing commas, unquoted keys, and single-quoted strings are syntax errors, and the page will refuse to compare until that side is valid. Fix the syntax, or use a JSON5/JSONC tool first, then paste the strict JSON here.

Does JSON Diff validate against a schema?

No. A successful compare only means both sides parsed as JSON. It does not check required fields, types, or a JSON Schema. Use the JSON Schema Validator page when you need that, then come back here to inspect a change.

Is my JSON sent to a server?

No. Parsing, formatting, and the line comparison all run in your browser. Closing the tab discards what you pasted. Do not paste documents that contain secrets if you would not be comfortable with them sitting in memory on this device.

Is there a file size limit?

There is no server-imposed limit, because nothing is uploaded. A few thousand lines is comfortable. Multi-megabyte exports can make the page feel slow; in that case, compare a smaller fixture or use a local tool.

How is this different from a plain text diff?

The visual result is still a line diff, like the text tool on the homepage. This page first requires valid JSON and re-indents both sides so a minified object and a pretty-printed copy of the same value usually line up. It does not yet compare objects by key independently of property order or line breaks.

Related tools and guides

References

  • RFC 8259 (the JSON data interchange format) defines objects, arrays, and values. Object key order is not significant, which is why a change of key order alone should not be treated as a semantic change.
  • JSON.parse and JSON.stringify are the browser APIs this page uses to validate and re-indent each side before the line comparison.
  • Libraries that compare JSON as a tree, such as a JSON Patch (RFC 6902) generator, are a better fit when you need a path-by-path change list rather than a highlighted line diff.