Skip to main content

JSON comparator

Compare two JSON documents and highlight structural differences. Processing stays local in your browser.

  • Clipboard
  • Export

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Was this tool useful?

How does this tool work?

Compare two JSON documents after normalizing layout and object property order. A one-line API response may therefore match the same response formatted differently. Value types and array order still matter: "1" is not the number 1, and a reordered list is different. Both sources stay in the browser. Output is a readable text report, not a new JSON document or a patch to apply automatically.

Both inputs must follow JSON syntax. The engine parses values, recursively sorts object keys and serializes them with common formatting. Layout whitespace and written property order stop producing artificial differences. Whitespace inside strings remains significant.

Arrays are not sorted and their objects are not matched by identifier. Moving an entry remains a difference. Strings, numbers, booleans and null are compared as parsed values. A missing key differs from a key containing null. Duplicate names follow JSON parsing behavior, retaining the last occurrence; avoid that ambiguous representation.

When normalized forms differ, each line is compared with the same position in the other document. - identifies the first input and + the second; shared lines have a space prefix. An insertion can shift several lines, producing a longer report than the smallest logical change. This is neither a path-based semantic diff nor JSON Patch.

Unsafe JavaScript integers and numbers parsed as nonfinite are rejected to avoid declaring distinct rounded identifiers equivalent. Decimal values still follow browser numeric precision. Use contractual string representations for long identifiers; choose text comparison when exact written tokens matter.

How to use this tool

  1. Supply both versions

    Paste or import each document separately. Put the reference first to read - as old values and + as new values.

  2. Run normalized comparison

    Read the equivalence message or report. Numeric rejection indicates a representation limit, not a calculated difference between the values.

  3. Inspect context and export

    Check surrounding lines before assuming several independent changes. Copy or download the .txt report. Editing either source hides old output.

Use cases

Compare API responses

Remove layout differences to inspect changed values. Preserve array order when positions belong to the contract.

Review JSON configuration

Compare reference and edited versions without confusing indentation with data changes. JSON5 comments are not supported.

Detect a type conversion

Find a number changed into a string or a boolean replaced with text even when their visual display looks similar.

Examples

Ignore object property order

Both objects have identical keys and values. Reordering properties introduces no structural difference after normalization.

Input

{"b":2,"a":1}
{"a":1,"b":2}

Result

The JSON documents are equivalent.

Distinguish number and string

The removed line contains a number and the added line a string. Quotes indicate a real type change rather than presentation.

Input

{"id":1}
{"id":"1"}

Result

  {
-   "id": 1
+   "id": "1"
  }

Tips and best practices

  • Remove volatile fields only when your comparison goal justifies it; timestamps are never ignored automatically.
  • A large report can result from shifted lines. Locate the first divergence before counting changes.
  • Use Spreadsheet Compare to match table rows by key rather than position.
  • Equivalent documents may both violate an API contract. Check the schema separately.

Sources and references

Frequently asked questions

Why can differently formatted files be equivalent?

Values are compared after sorting object properties and applying common layout. Presentation whitespace and key order alone do not change an object.

Are arrays compared without considering order?

No. Entry order remains significant. The engine does not search for id fields or automatically match moved objects.

Can I apply the report as JSON Patch?

No. The - and + signs describe a text report on normalized documents. Output does not contain JSON Patch operations and paths.

Why are some large numbers rejected?

JavaScript parsing could round distinct integers to the same value. Rejection prevents false equivalence. Use string identifiers when your contract allows them.

Related tools

Tools similar or complementary to this one.

Similar tools

Format, minify, and validate JSON to make it easier to read or more compact.

DevelopmentFeaturedUse this tool

Validate a JSON document against a schema and locate every error precisely.

DevelopmentFeaturedUse this tool