JSON Compare Tool (Diff & Patch)

Quick Start: Compare two JSON files

JSON Compare highlights additions, deletions, and modifications between two JSON documents. You can ignore whitespace/case/order and export a JSON Patch or a Markdown report.

  1. Paste or Import JSON A on the left; JSON B on the right.
  2. Toggle options: Ignore whitespace, case, or order.
  3. Review highlighted differences in the diff viewer.
  4. Copy summary, export report, or export JSON Patch.
A: JSON A (Default)
B: JSON B (Default)
Loading...

Frequently Asked Questions

How does JSON comparison work?

The tool uses structural comparison to identify differences between two JSON objects. It detects additions, deletions, and modifications at any nesting level, providing a visual side-by-side diff view.

Does this upload my JSON files?

No, the tool works offline in your browser. Your JSON data is processed locally and never uploaded to our servers.

What comparison options are available?

You can ignore whitespace differences, case sensitivity, and object/array order. These options help focus on meaningful structural changes rather than formatting differences.

Can I ignore whitespace?

Yes, you can ignore whitespace. The tool will ignore differences in whitespace within string values (e.g., 'Hello, World' vs 'Hello,World'). Whitespace outside of strings is already ignored by JSON parsing.

Can I ignore case?

Yes, you can ignore case. The tool will compare keys and string values case-insensitively by lowercasing them before diffing. For example, 'Status' and 'status', or 'SUCCESS' and 'success', are treated as equal.

Can I ignore key order?

Yes, you can ignore key order. The tool will sort object keys and array elements using a stable comparator before diffing, so reordering does not count as a change. This works for arrays of primitives and objects (objects are compared via their JSON representation).

Why is the editor sometimes read-only?

When any ignore option is enabled, the view switches to a normalized preview so that visual highlighting matches the ignore rules exactly. Disable all ignore options to return to the editable raw view.

How do I interpret the diff results?

Green highlights show additions, red shows deletions, and yellow shows modifications. The statistics panel provides a summary of total changes, and the diff can be exported as a detailed report.

Can I compare large JSON files?

Yes, the tool can handle large JSON files efficiently. For very large files, consider using the 'ignore whitespace' option to improve performance and focus on structural differences.

What file formats are supported?

You can import .json and .txt files, or paste JSON content directly. The tool validates JSON syntax and provides helpful error messages for invalid JSON.

How can I export the comparison results?

Use the 'Export Report' button to download a detailed markdown report, or 'Copy Diff' to copy a summary to your clipboard. The report includes statistics and detailed change descriptions.

Can I merge changes by path?

Yes, you can merge changes by path. The tool will merge changes by path. For example, if you have a JSON object with a key 'name', and you want to merge changes by path, you can use the 'Merge by path' button to merge changes by path.

How large can my files be??

The tool can handle large JSON files efficiently. For very large files, consider using the 'ignore whitespace' option to improve performance and focus on structural differences.

What is JSON Patch (RFC 6902)?

JSON Patch is a standard format for describing how to transform one JSON document into another using a list of operations such as add, remove, and replace. Use the 'Export JSON Patch' button to download a patch that turns A into B.

How is the exported JSON Patch generated?

We compute a minimal, reliable set of operations from A → B. Object field additions/removals are emitted as add/remove at their JSON Pointer paths, and changed values as replace. Arrays are exported conservatively as a single replace when contents differ to avoid index drift issues.

How can I apply a JSON Patch?

In JavaScript, you can use libraries like fast-json-patch: applyPatch(original, patch). In other languages, search for 'JSON Patch RFC 6902' libraries. The patch we export follows the standard and should work across implementations.