JSON Diff - Compare JSON Online

Paste two JSON documents and see what actually changed. Keys are sorted first, so reordering never shows up as a difference.

100% client-side ยท your data never leaves your browser
โ„น๏ธ How to Compare Code & Text
  • Paste or type code/text in the textareas above - differences appear automatically in the side-by-side diff view below
  • Automatic Language Detection - Detects programming language and applies syntax highlighting for code comparison (supports 20+ languages including JavaScript, Python, Java, and more)
  • Ignore Whitespace & Formatting - Enable this option to focus on actual code changes, ignoring indentation and spacing differences
  • The diff editor is fully editable - modify both original and modified code directly in the comparison view
  • Visual diff markers highlight additions (green), deletions (red), and line-by-line modifications for easy code review
  • Navigate between changes using the overview ruler on the right side
  • Switch between light and dark themes for comfortable code viewing
โœ… Professional Code Diff Editor

Powered by Monaco Editor - the same diff viewer that powers VS Code for professional code comparison

๐ŸŽฏ Smart Syntax Highlighting

Automatically detects programming language and applies syntax highlighting for accurate code diff analysis

โšก Interactive Diff View

Edit both original and modified code directly in the side-by-side comparison view

๐Ÿ”’
100% Client-Side Code Comparison- Your code and text never leave your browser

๐Ÿ“– How to Use

  1. Paste the original JSON in the left box.
  2. Paste the changed JSON in the right box.
  3. The side-by-side diff appears below. Added lines are green and removed lines are red.
  4. Leave "Sort keys & format" on to ignore key order and indentation. Turn it off to see the raw text difference.
  5. Click "Load Example" to see how a reordered object compares.

About the JSON Diff Tool

A regular text diff compares lines, so if the indentation changes or a serializer writes fields in a different order, every line lights up even though the data is identical. This tool normalizes both documents before it compares them.

Before the diff runs, each side goes through three steps:

  1. It's parsed with the browser's own JSON.parse, so invalid input is caught right away.
  2. Every object's keys are sorted alphabetically, at every level of nesting.
  3. The result is printed with two-space indentation, one value per line.

What's left in the diff are real changes: a value that changed, a key that was added or removed, or an array whose items differ. The diff view is the same Monaco editor that VS Code uses, with JSON syntax highlighting.

If you need a line-by-line comparison of arbitrary text or code, use the Diff Checker. To tidy or validate a single document, use the JSON Formatter.

Example: same data, different order

These two objects hold the same data:

{"id": 7, "tags": ["a", "b"], "owner": {"name": "Lin", "team": "api"}}
{"owner": {"team": "api", "name": "Lin"}, "id": 7, "tags": ["a", "b"]}

A text diff marks every line as changed. With key sorting on, JSON Diff reports no differences. Change "team": "api" to "team": "web" and that single line is the only one highlighted.

Common uses

  • Checking an API response against the expected payload in a test.
  • Reviewing changes to package.json, tsconfig.json or other config files.
  • Comparing feature-flag or i18n files exported from different environments.
  • Spotting what changed between two versions of a database or webhook export.

โ“ Frequently Asked Questions

How is a JSON diff different from a normal text diff?

A text diff compares lines. Two JSON files with the same data but different key order or indentation look completely different to it. This tool parses both sides, sorts every object's keys alphabetically and re-indents them before comparing, so the diff only shows changed values, added keys and removed keys.

Does key order matter when comparing JSON?

No. The JSON spec treats an object as an unordered set of name/value pairs, so {"a":1,"b":2} and {"b":2,"a":1} are the same data. With "Sort keys & format" on (the default), this tool treats them as equal. Turn the option off if you need to see the raw text difference.

Is array order ignored too?

No. Array order is part of the data in JSON: [1, 2] and [2, 1] are different values. The tool keeps arrays in their original order and only sorts object keys, including keys of objects nested inside arrays.

What happens if one side is not valid JSON?

You get an error message with the parser's reason (for example an unexpected token or a trailing comma), and that side is compared as plain text instead. Fix the error, or run it through the JSON Formatter to find the exact line.

Can I compare API responses with this tool?

Yes, that is one of the most common uses. Paste the expected response on the left and the actual one on the right. Because key order is normalized, you won't get noise from a server or serializer that orders fields differently between runs.

Is my JSON sent to a server?

No. Parsing, sorting and diffing all run in your browser with JavaScript. Nothing you paste is uploaded or stored, so it is safe to compare configs, tokens or customer data.

How large can the JSON files be?

Files of a few thousand lines compare quickly on a normal laptop. Very large documents (tens of megabytes) depend on your browser's memory. For those, a command-line tool such as jq with diff is a better fit.

๐Ÿ”— Related Tools