Generate JSON Patch
from JSON Diff
Compare two JSON documents and generate a list of RFC 6902 JSON Patch operations (add, remove, replace). Instantly see what changed — and how to apply it programmatically.
Open JSON Diff ToolRFC 6902 patch operations in four steps
No account. No upload. No nonsense.
No Server
Your JSON never leaves your device. There is no backend to send it to.
RFC 6902 Compliant
Diff output maps directly to standard JSON Patch operations — add, remove, replace.
Works Offline
Load once and use forever — even on a plane or without internet access.
Related JSON tools
Common questions answered
What is a JSON Patch (RFC 6902)?
JSON Patch is a format for describing changes to a JSON document. Defined in RFC 6902, it uses an array of operations (add, remove, replace, move, copy, test) that can be applied to transform one JSON document into another.
How do I use JSON Patch in my code?
Apply patch operations using libraries like fast-json-patch (JavaScript), jsonpatch (Python), or json-patch (Go). The patch array from the diff tool can be passed directly to these libraries.
Does my data leave my browser?
No. All diff and patch generation is 100% client-side — your JSON never leaves your device.
What is the difference between JSON Diff and JSON Patch?
JSON Diff shows what changed in a human-readable format. JSON Patch (RFC 6902) is a machine-readable list of operations that can be programmatically applied to reproduce those changes.
Can JSON Patch handle array changes?
Yes. Array element additions, removals, and replacements are represented as add, remove, and replace operations with index-based paths like /items/0.
What is JSON Patch (RFC 6902)?
JSON Patch is a standard (RFC 6902) for describing changes to a JSON document as a sequence of operations. Each operation specifies an action (add, remove, replace, move, copy, or test) and a JSON Pointer path. Patches are compact, explicit, and can be applied atomically — ideal for partial updates in REST APIs and synchronization protocols.
This tool generates a JSON Patch by comparing two inputs: original and modified. The output is an array of operations that, when applied to the original, produce the modified version. This is useful for APIs accepting PATCH requests, building audit logs of changes, and implementing optimistic concurrency control.
// Before
{"name":"Alice","age":30}
// After
{"name":"Alice","age":31,
"title":"Senior"}
[
{"op":"replace",
"path":"/age",
"value":31},
{"op":"add",
"path":"/title",
"value":"Senior"}
]
Get the most out of this tool
- Use JSON Patch for API endpoints that update partial resources — it is more efficient than sending the entire object.
- The "test" operation verifies a field value before applying changes — use it for optimistic concurrency control.
- JSON Patch operations are applied in order — the sequence matters when operations depend on previous changes.
RFC 6902 JSON Patch explained
JSON Patch (RFC 6902) is a format for expressing a sequence of operations to be applied to a JSON document to transform it from one state to another. Rather than sending a complete replacement document, a JSON Patch contains only the changes — making it ideal for REST API PATCH operations, collaborative editing systems, and change auditing. The format is widely supported by HTTP clients, JSON processing libraries, and API gateways.
A JSON Patch document is a JSON array of operation objects. Each operation object has an "op" field specifying the operation type and a "path" field specifying the target location using JSON Pointer (RFC 6901) syntax. The six operations are: "add" (adds a value at a path), "remove" (removes a value at a path), "replace" (replaces a value), "move" (moves a value from one path to another), "copy" (copies a value from one path to another), and "test" (tests that a value equals an expected value).
JSON Pointer is the addressing syntax used by JSON Patch. A JSON Pointer is a string starting with "/" and then listing path segments separated by slashes. For example, "/address/city" refers to the "city" field inside the "address" object. For arrays, the index is used: "/items/0" refers to the first element. The special token "-" refers to the element after the last element of an array, used with "add" to append. Slashes and tildes in key names are encoded as "~1" and "~0".
The JSON Patch generator compares two JSON documents and produces the minimal set of patch operations that transforms the first (original) into the second (target). "Minimal" means using "move" instead of "remove" + "add" when a value moves between paths, and "replace" instead of "remove" + "add" when only the value changes. A minimal patch is smaller and more semantically meaningful — it communicates intent, not just mechanics.
The "test" operation is unique among JSON Patch operations — it does not modify the document but asserts that a value at a given path equals an expected value. If the test fails, the entire patch operation fails and no changes are applied. This enables optimistic concurrency control: include test operations at the beginning of a patch to verify the document has not changed since you last read it. If another client modified the same field concurrently, your patch fails safely rather than silently overwriting their changes.
JSON Patch is more precise than JSON Merge Patch (RFC 7396) but more complex. Merge Patch is simpler — you send a partial document where null values delete keys. JSON Patch supports operations that Merge Patch cannot express: moving values, copying values, testing preconditions, and appending to arrays. For REST APIs, Merge Patch is easier to implement and use for simple updates; JSON Patch is better for complex operations and when you need atomic test-then-modify semantics.
When developers use this tool
Additional frequently asked questions
What is the difference between JSON Patch and JSON Merge Patch?
JSON Patch (RFC 6902) uses an explicit list of operations (add, remove, replace, move, copy, test) with JSON Pointer paths. JSON Merge Patch (RFC 7396) sends a partial document where present non-null values replace, null values delete, and absent keys are unchanged. Merge Patch is simpler; JSON Patch is more expressive and supports atomic test preconditions and move/copy operations.
How do I apply a JSON Patch in my programming language?
Most languages have JSON Patch libraries: fast-json-patch (JavaScript), jsonpatch (Python), zjsonpatch (Java), json-patch (Go), and JsonPatch.Net (C#). Call the library's apply() function with the original document and the patch array. The library validates each operation and applies them in sequence, returning the patched document or an error if any operation fails.
Can a JSON Patch be reversed (undone)?
An "add" operation can be reversed with "remove". A "remove" operation can be reversed with "add" at the same path. A "replace" can be reversed by replacing with the old value. A "move" reverses by moving back. To generate a reverse patch, you need both the patch document and the original document — so the reverse operations can include the original values that were overwritten.
Is JSON Patch atomic? Do all operations succeed or none?
Per RFC 6902, JSON Patch is atomic: if any operation in the patch fails (including "test" operations), the entire patch is rejected and no changes are applied. This all-or-nothing behavior prevents partial updates that would leave the document in an inconsistent state. Library implementations may vary in how strictly they implement this atomicity guarantee.