Skip to content

Query & Inspect JSON

How to Compare Two JSON Documents

A structural diff shows which data changed and where, without treating whitespace or formatting as a meaningful difference.

Last updated: October 24, 2026

When an API response or configuration changes, a structural comparison helps isolate the data difference. The MyJSONPal JSON Diff tool parses both inputs as JSON and reports added, removed, changed, and type-changed values at their paths. It compares in your browser; both inputs must be valid JSON.

Structural diff vs. text diff

A text diff compares characters and lines, so formatting changes can make many lines look different. A JSON structural diff parses the documents first. Reindenting an object or changing insignificant whitespace does not change the underlying values; adding a key or changing a number to a string does.

For example, these documents have the same JSON value despite different formatting:

{"status":"ready","count":2}
{
  "status": "ready",
  "count": 2
}

Read a small before-and-after comparison

Before:

{
  "user": { "name": "Ari", "active": true },
  "tags": ["api", "internal"]
}

After:

{
  "user": { "name": "Ari Singh", "active": "true", "role": "editor" },
  "tags": ["api", "public"]
}

The structural changes are:

  • $.user.name changed from "Ari" to "Ari Singh".
  • $.user.active changed type from boolean to string.
  • $.user.role was added.
  • $.tags[1] changed from "internal" to "public".

Paths identify the location; before-and-after values explain the change. A summary can help scan the total additions, removals, and changes before inspecting individual entries.

Arrays are compared by index

Array items are matched by position, not by a guessed identifier. If an item is inserted at the start, later items may appear changed at their new indexes. The diff does not infer that a record moved or use an id field to pair records. For a meaningful record-by-record comparison, sort or align both arrays by a stable key before comparing them.

A reliable comparison workflow

  1. Use the same environment, request, and relevant options for both captures.
  2. Validate that both inputs are JSON. A syntax error prevents a structural comparison.
  3. Compare the documents and read the exact path for each difference.
  4. Interpret array changes with index-based matching in mind before treating them as record changes.
  5. Copy or download the resulting diff when you need to keep a review artifact.

If the only difference is formatting, the JSON formatter can normalize the text. If you want to extract a subset of nested values instead of comparing whole documents, use the JSONPath evaluator.