Just Formatter

JSON Diff & Compare Tool

Paste two JSON objects and instantly see a color-coded side-by-side diff — nothing uploaded, runs in your browser.

Original JSON (A)
Modified JSON (B)

Paste JSON in both panels and click Compare JSON

Or try Load Sample to see a demo diff

How to Compare JSON — 3 Steps

  1. 1
    Paste your two JSON inputs. Paste the original JSON into the left panel (A) and the modified JSON into the right panel (B). Both inputs are independently validated — if either contains a syntax error, the specific error and position are shown below that panel.
  2. 2
    Click Compare JSON. The tool parses and formats both inputs with 2-space indentation, then runs a line-level diff algorithm. The comparison is instant for typical API responses and configuration files.
  3. 3
    Read the color-coded diff. Lines removed from A are highlighted in red on the left. Lines added in B appear in green on the right. Unchanged lines appear in both columns at the same row. The stats bar shows the total count of added, removed, and unchanged lines.

What is JSON Diff?

A JSON diff is a comparison between two JSON documents that shows exactly what changed — which fields were added, which were removed, and which values were modified. It is the JSON equivalent of git diff, applied to structured data instead of source code.

JSON is widely used in API responses, configuration files, database exports, and application state. When a JSON payload changes — between API versions, environment configs, or test runs — a visual diff immediately answers the question “what exactly is different?” without manually scanning two documents.

This tool uses a line-level diff based on the Longest Common Subsequence (LCS) algorithm. Both inputs are first normalized to identical formatting (2-space indentation, sorted keys within each object), so purely cosmetic differences — whitespace, key order — are eliminated before the comparison runs.

How the Diff Algorithm Works

The comparison uses the Longest Common Subsequence (LCS) algorithm — the same algorithm used by diff and git diff. It finds the largest set of lines that appear in both documents in the same order, then treats everything outside the LCS as either a deletion (from A) or an insertion (into B).

Removed (red, −)

Lines that exist in the Original (A) but not in Modified (B). These appear only on the left side.

Added (green, +)

Lines that exist in Modified (B) but not in Original (A). These appear only on the right side.

Unchanged

Lines that are identical in both documents. They appear at the same row on both sides.

The algorithm pre-processes both JSONs through JSON.parse → JSON.stringify(…, null, 2) before diffing. This means a minified JSON and a pretty-printed version of the same data will compare as identical — the diff reflects structural and value changes, not formatting choices.

When Developers Use JSON Diff

API response debugging

Compare what an endpoint returns in staging vs. production to find undocumented field changes, missing keys, or unexpected value types between environments.

API version migration

Diff a v1 and v2 API response to build a migration checklist. See exactly which fields were renamed, removed, or added to the new contract.

Configuration auditing

Compare application config files (appsettings.json, package.json, terraform state) before and after changes to confirm exactly what was modified and what was not.

Test assertion debugging

When an expected vs. actual JSON assertion fails in a test suite, paste both into the diff tool to immediately see which field is wrong rather than reading a raw inequality message.

Feature flag and schema changes

Diff JSON schemas or feature flag payloads across releases to document what changed for changelog entries, rollback plans, or code review.

Data pipeline validation

Compare a JSON record before and after a transformation step to verify the pipeline is producing the correct output — especially useful for ETL, normalization, and enrichment stages.

Reading the Diff Output

The side-by-side layout mirrors the classic git diff view. Each row in the diff table represents a line. Rows are aligned so that matching unchanged lines appear at the same vertical position, making it easy to see which changes are adjacent.

Line numbers. Each non-empty row shows the line number in that document in the left gutter. Line numbers are independent for A and B — a deletion in A does not shift B's line numbers.
The − and + prefixes. A minus sign marks a removed line; a plus sign marks an added line. Empty cells (where one side has no matching line) are shown with a neutral background.
Consecutive changes. When multiple lines changed together (e.g., a nested object was replaced), the removed block on the left is paired with the added block on the right. If the blocks are different sizes, empty rows pad the shorter side.
Stats bar. The summary at the top of the diff counts total removed lines, added lines, and unchanged lines across the entire document.

Limitations and Edge Cases

  • Line-level, not semantic. The diff operates on formatted text lines, not JSON values. If a nested object moves position within the document, the diff will show it as deleted in one place and added in another rather than as a “move” operation.
  • Key ordering. JSON.stringify preserves JavaScript insertion order. If the same keys appear in different orders in A and B, the formatted output will reflect that, and the diff will show changes even if all values are the same.
  • Large documents. The LCS algorithm has O(m×n) complexity. Documents producing more than 2,000 lines each may take a second or two on older devices.
  • No semantic array diff. Arrays are compared as sequences of lines. Inserting an element at position 0 of a 10-element array will look like “every line changed” rather than “one element inserted.”

Frequently Asked Questions

How do I compare two JSON objects online?

Paste your original JSON into the left panel (A) and your modified JSON into the right panel (B), then click Compare JSON. The tool shows a side-by-side diff with removed lines highlighted in red and added lines in green.

Does this tool handle nested JSON objects?

Yes. The diff works on the formatted JSON text — nested objects and arrays are fully supported. The tool formats both JSONs before diffing so indentation differences do not produce false positives.

Does formatting (whitespace) affect the comparison?

No. Both inputs are parsed and re-formatted with identical 2-space indentation before the diff runs. This means a minified and a pretty-printed version of the same data will compare as identical.

Is my JSON sent to a server?

No. All parsing and comparison runs entirely in your browser using JavaScript. Your JSON data never leaves your device and is not stored anywhere.

What is the maximum JSON size this tool handles?

There is no server-side limit. Performance depends on your device. JSONs producing fewer than 2,000 lines when formatted compare instantly. Very large documents (50 MB+) may take a few seconds.

Why does the diff show changes when I only changed key order?

The diff is text-based on formatted output. JSON parsers do not guarantee key order, but JSON.stringify preserves insertion order in modern JavaScript engines. If you want order-insensitive comparison, sort both JSONs before comparing.

From the Blog

Related Tools