JSON Patch · RFC 6902 · runs in your browser
JSON Patch Generator
Paste the original JSON and the changed JSON: you get the RFC 6902 patch that turns one into the other, with every operation replayed on the original to check it.
[]
Nothing is uploaded: both documents are parsed and patched inside this tab. Every patch is checked by replaying it on the original and comparing the result with the changed document.
An RFC 6902 JSON Patch is a list of operations that turns one JSON document into another. Paste the original in Original (A) and the changed version in Changed (B), press Generate patch, and the tool walks both trees and writes the operations for you — with JSON Pointer paths such as /order/status and /items/2.
What the operations mean
A patch is always a JSON array. Each entry has an op, a path, and — for add and replace — a value.
replace— the value at that path is different in B.add— a key or array slot exists in B and not in A.remove— a key or array slot exists in A and not in B.
The path syntax is JSON Pointer (RFC 6901): a leading / is the root, /a/b goes into b of a, and ~0 / ~1 escape ~ and / inside a key name.
The three examples loaded above
Replace a field. A status change and a price change produce two operations:
[
{ "op": "replace", "path": "/order/status", "value": "paid" },
{ "op": "replace", "path": "/order/total", "value": 138.5 }
]
Add an array item. One new element at the end, plus the counter that changed with it:
[
{ "op": "replace", "path": "/count", "value": 3 },
{ "op": "add", "path": "/items/2", "value": "sku-3" }
]
Remove a property. A field the API stopped returning:
[ { "op": "remove", "path": "/customer/legacyId" } ]
How to apply the patch
In Node.js, fast-json-patch takes the document and the array: applyPatch(doc, patch). In Python, the jsonpatch package does the same: jsonpatch.apply_patch(doc, patch, in_place=True). Over HTTP, send PATCH with Content-Type: application/json-patch+json and the patch array as the body — that is exactly what the format was designed for.
Save the patch with Download .json when you want to commit it as a fixture in your test suite, or copy it into a PR description to show what changed between two payloads.
Why send a patch instead of the whole document
A patch is smaller, reviewable and it names what changed. In a code review, twelve operations on specific paths say far more than two full payloads side by side. For an API that returns large lists, the patch for one changed item is a handful of lines instead of megabytes.
Verified before you use it
This tool does not hand you an unverified guess. After building the operations it replays them on document A and deep-compares the result with document B; the status line reports whether the replay reproduced B exactly. Arrays are compared by position — if items move around and your data carries stable ids, use compare with array order ignored instead, or read the line-by-line diff view first to see what changed before deciding on a patch.
Frequently asked questions
How do I generate a JSON Patch from two JSON documents?
Paste the earlier document in Original (A) and the later one in Changed (B), then press Generate patch (or Ctrl / Cmd + Enter). The tool walks both trees and writes an array of add, remove and replace operations with JSON Pointer paths. Nothing is uploaded: the comparison runs in your browser tab.
How do I know the patch is correct?
Every generated patch is replayed on document A inside the page, and the result is compared with document B. If the replay reproduces B exactly, the status line says so; if it does not, you are told the patch would not apply cleanly.
How do I apply the JSON Patch in code?
In Node.js use fast-json-patch: applyPatch(doc, patch). In Python use the jsonpatch package: jsonpatch.apply_patch(doc, patch, in_place=True). In an HTTP request send PATCH with Content-Type application/json-patch+json and the patch array as the body.
Does it match array items by id or key?
No. Arrays are compared by position, which is what RFC 6902 assumes: if an item moves, the patch shows a remove and an add rather than a move. If your arrays carry stable ids and order does not matter, use the compare tool on the homepage with array order ignored instead.
What is the difference between JSON Patch and JSON Merge Patch?
JSON Patch (RFC 6902) is an explicit list of operations — add, remove, replace — each with a path and a value. JSON Merge Patch (RFC 7386) is a partial document: keys you include overwrite the target, keys set to null delete. Patch is precise and replayable; merge patch is shorter but cannot express every change.