Skip to content

JSON Compare — Diff Two JSON Objects Online

Compare two JSON objects side by side and see structural differences — added, removed, and changed keys, with full paths. Free and browser-based.

Last updated:

JSON Diff vs. Text Diff

A standard text diff compares files line by line, which means that insignificant changes like whitespace, indentation, or key reordering produce noisy results. JSON is a structured format, and comparing it structurally rather than textually yields far more meaningful output. A JSON diff engine parses both documents into object trees and walks them recursively, reporting only the values and keys that actually changed.

Because the comparison operates on parsed data, two documents that are semantically identical but formatted differently will show zero differences. Key order is irrelevant: { "a": 1, "b": 2 } and { "b": 2, "a": 1 } are treated as equal. This is the core advantage over a line-based text diff tool: you see what changed in the data, not how the file was reformatted.

The diff output also includes full paths to every change. Instead of a vague "line 47 differs," you get a precise location like user.address.zipCode, making it immediately clear which part of your data structure was affected.

How to Compare Two JSON Files Online

Comparing JSON online takes a few seconds and nothing is uploaded — the diff runs entirely in your browser:

  1. Paste the original JSON into the left panel. This is your baseline: the old API response, the committed config, the expected test fixture.
  2. Paste the new JSON into the right panel. To compare two JSON files, open each in an editor and copy the contents across.
  3. Read the change list. Every difference is listed with its full path and marked as added, removed, or changed, with old and new values shown side by side.
  4. Fix syntax errors first if you see one. Both inputs must be valid JSON. If either fails to parse, run it through the JSON validator to find the bad comma or quote, then compare again.

If both inputs are valid and the tool reports no differences, the two documents hold identical data — even if their formatting, indentation, or key order differ.

When You Need a JSON Diff

Structural JSON comparison is useful in a wide range of development and operations workflows. Here are some of the most common scenarios:

  • API response comparison. When you refactor an endpoint or upgrade a dependency, diff the response payloads before and after the change to verify nothing broke. Even a single missing field or changed type can cascade into frontend bugs.
  • Configuration drift detection. Infrastructure-as-code tools export JSON configs. Comparing the expected config against the live state reveals unintended manual edits, merged defaults, or version-related changes that drifted from the baseline.
  • Database migration verification. After running a migration that transforms stored JSON columns, you can diff sample rows to confirm the transformation applied correctly and no data was lost or truncated.
  • Test fixture validation. Golden-file tests store expected JSON output. When a test fails, diffing the expected and actual payloads pinpoints the exact fields that diverged, cutting debug time significantly.
  • Code review support. When a pull request modifies a large JSON file (translations, feature flags, permissions), a structural diff highlights real content changes and suppresses formatting noise from linters or auto-formatters.

Understanding the Diff Output

The JSON diff tool categorizes every difference into one of three types, each color-coded for quick scanning:

  • Added keys (green). A key or array element exists in the right-hand document but not in the left. This means new data was introduced. The diff shows the full path and the new value.
  • Removed keys (red). A key or array element exists in the left-hand document but is absent on the right. This signals deleted data. Pay close attention to removals during migrations or refactors, as they can indicate accidental data loss.
  • Changed values (yellow/modified). The key exists in both documents but holds a different value. The output shows the old value and the new value side by side, along with the nested path. Type changes are also flagged here. For example, a number 42 becoming a string "42" is a meaningful change that a text diff might overlook entirely.

Nested paths use dot notation, so a change three levels deep appears as something like order.items[0].price. This makes it straightforward to locate the affected key in your source data, even in deeply nested documents with hundreds of fields.

Comparing JSON Arrays

Objects and arrays are compared differently. Object keys are matched by name, so key order never matters. Array elements are matched by position: element [0] on the left is compared with element [0] on the right, and so on. Array order is part of the data in JSON, so [1, 2, 3] and [3, 2, 1] are reported as different.

One side effect: inserting an element near the start of an array shifts every element after it, so the diff reports a change at each later index plus an addition at the end. When that happens, look at the first changed index — that is usually where the real edit is. If your array is really an unordered set (tags, roles, permission lists), sort both sides the same way before comparing to get a clean result.

Arrays of objects work the same way, recursively: users[2].email means the third user's email changed, while users[4] listed as added means the right-hand array is longer.

Tips for Meaningful JSON Comparisons

Getting the most out of a JSON diff sometimes requires a small amount of preparation. These practices help reduce noise and surface the differences that actually matter:

  • Format both documents first. While the diff engine ignores whitespace, using a JSON formatter on each input before pasting improves readability if you need to cross-reference the raw text alongside the diff output.
  • Sort keys consistently. Some diff algorithms are sensitive to array order. If your arrays represent unordered sets (like tags or permissions), sorting them alphabetically before diffing prevents false positives caused by different insertion orders.
  • Normalize types before comparing. If one system serializes numbers as strings, the diff will flag every such field. Decide upfront whether "1" and 1 should be treated as equal or not, and normalize accordingly.
  • Ignore volatile fields for semantic diffs. Timestamps like createdAt, auto-incremented IDs, and request identifiers change on every call. Stripping or masking these fields before diffing keeps the output focused on intentional changes.
  • Diff in both directions. Swapping the left and right inputs can surface asymmetries you might miss on the first pass. An "added" key becomes "removed" and vice versa, giving you a different perspective on the same change set.

Related Tools

Depending on your workflow, you may find these complementary tools useful alongside the JSON diff:

  • Diff Checker -- a general-purpose text diff tool for comparing any two blocks of text line by line. Best for non-JSON content like configuration files, code snippets, or prose.
  • JSON Formatter and Validator -- validates and pretty-prints JSON before you diff it. Catches syntax errors early so the diff tool can parse both inputs cleanly.
  • JSON Viewer -- an interactive tree viewer for exploring large JSON documents. Useful when the diff flags a deep path and you need to navigate the full structure to understand the context around the change.

Frequently Asked Questions

How is this different from a text diff?
A text diff compares raw text line by line. JSON Diff understands JSON structure — it compares keys and values recursively, so reformatting or reordering keys won't show as differences.
Does it handle nested objects?
Yes. The tool recursively traverses nested objects and arrays, showing the full path (e.g. 'user.address.city') for each difference.
Is my JSON data kept private?
Yes. This tool runs entirely in your browser. Your JSON is never sent to any server.
How does JSON Diff handle key order?
Object keys are compared by name, not position, so reordering keys does not show as a diff. Arrays, however, are position-sensitive — moving an element to a different index is reported as a change.
What counts as a type change?
Different JSON types count as changes: `"42"` (string) vs `42` (number) is flagged, as is `null` vs an empty object. If you only care about semantic equality, normalize your data first.
Can I see the JSON path to each changed field?
Yes. The diff output shows each change with a path like `users.0.email`. Copy the path to navigate directly to the differing field in your source data.
How do I compare two JSON files online?
Open each file, paste the original into the left panel and the new version into the right. The tool parses both and lists every added, removed, and changed key with its full path. Nothing is uploaded — the comparison runs in your browser.
Does array order matter when comparing JSON?
Yes. Arrays are compared position by position, because order is part of the data in JSON — [1, 2] and [2, 1] are different. Object key order, on the other hand, is ignored. If an array is really an unordered set, sort both sides before comparing.

Related Tools