JSON Diff & Patch Tool

Compare two JSON documents and generate RFC 6902 add, remove and replace operations. Review and copy the patch locally.

Loading tool module...

About this json diff & patch tool

Compare two JSON payloads structurally and generate RFC 6902 JSON Patch operations.

How this tool works

Compares two JSON documents and generates RFC 6902 add, remove and replace operations. Object keys use RFC 6901 escaping: ~ becomes ~0 and / becomes ~1. An empty path addresses the whole document. Changed arrays are replaced as a whole; structurally equal arrays produce no change.

  1. Enter 1 in the first input and 2 in the second input.
  2. Choose Run locally to generate the patch.
  3. Check that the replace operation has an empty path, then copy the output.

Worked example

Scenario: Enter 1 in the first input and 2 in the second input.

Sample input:

1

Processing: Enter 1 in the first input and 2 in the second input. Compares two JSON documents and generates RFC 6902 add, remove and replace operations. Object keys use RFC 6901 escaping: ~ becomes ~0 and / becomes ~1. An empty path addresses the whole document. Changed arrays are replaced as a whole; structurally equal arrays produce no change.

Illustrative output:

[ { "op": "replace", "path": "", "value": 2 } ]

Limits and verification

Each document is limited to 1,000,000 UTF-16 code units and 100 nesting levels; output is limited to 8,388,608 code units. Duplicate keys, unsafe integers, overflow, underflow and decimal values that cannot retain their value on serialization are rejected. Quote exact large or high-precision values as strings. Formatting whitespace outside strings and object key order are not differences; whitespace inside strings remains significant. This generates a patch but does not apply one, generate JSON Merge Patch or guarantee the smallest patch. No file input or download is offered. Text must contain valid Unicode; unpaired UTF-16 surrogates are rejected.

Examples demonstrate an expected workflow; they do not prove every input or every branch of an external specification. Check important results with an independent source before using them for money, security, compliance, safety, or irreversible file changes.

Browser processing boundary

Tool input is processed by code running in the browser and is not intentionally sent to a CZOA processing API. The page can still request ordinary site assets, analytics, or advertising when those services are enabled. Browser extensions and managed-device software remain outside this tool's control.

Relevant references

These references govern or help explain the format, protocol, or calculation used here. Listing a reference does not claim certification or complete implementation of every optional feature.

Content owner: CZOA Tools · Last reviewed: 2026-09-15 · Review methodology

How to use it

  1. Enter 1 in the first input and 2 in the second input.
  2. Choose Run locally to generate the patch.
  3. Check that the replace operation has an empty path, then copy the output.

Frequently asked questions

How do I compare two documents with JSON Diff?+

Enter the first JSON in Input and the comparison JSON in Second input / expression, then press Run locally. For {"a":1} versus {"a":2,"b":true}, the output contains replace for /a and add for /b.

What patch format and path escaping does the output use?+

It emits add, remove, and replace objects in a JSON Patch array. Object-key paths escape ~ as ~0 and / as ~1; an empty path represents replacing the document root.

How are arrays and object-key ordering compared?+

Object member order and formatting whitespace outside strings do not create a difference. A changed array is replaced as a whole, so this generator does not promise the smallest possible edit sequence.

Can JSON Diff apply its patch or accept unsafe JSON numbers?+

It generates a patch only; it does not apply it or create Merge Patch. Duplicate keys, unsafe integers, lossy decimals, invalid Unicode, excessive nesting, and documents over the stated limits are rejected before comparison.