JSON Patch Builder
Paste source and target JSON. The builder emits a minimal RFC 6902 patch
(add, remove, replace, copy, move, test) and verifies it by re-applying to the source.
[
{
"op": "replace",
"path": "/user/name",
"value": "Ada L."
},
{
"op": "add",
"path": "/user/roles/2",
"value": "owner"
},
{
"op": "add",
"path": "/user/verified",
"value": true
},
{
"op": "replace",
"path": "/settings/theme",
"value": "dark"
},
{
"op": "add",
"path": "/settings/locale",
"value": "en-GB"
},
{
"op": "remove",
"path": "/tags/0"
},
{
"op": "add",
"path": "/tags/1",
"value": "gamma"
}
]{
"user": {
"id": 42,
"name": "Ada L.",
"email": "ada@example.com",
"roles": [
"admin",
"editor",
"owner"
],
"verified": true
},
"settings": {
"theme": "dark",
"notifications": true,
"locale": "en-GB"
},
"tags": [
"beta",
"gamma"
]
}About the JSON Patch Builder
The JSON Patch Builder diffs two JSON documents and produces a JSON Patch — a standardized array of operations defined by RFC 6902. JSON Patch is the canonical way to describe partial updates to a JSON document, used by Kubernetes, OpenAPI, Azure Resource Manager, and many REST APIs.
Paste a source document on the left, edit your target on the right, and the tool emits a
minimal patch made of add, remove, replace, copy, move, and test operations. Every patch is immediately re-applied
to the source so you can verify it produces the expected target — 100% client-side, no data leaves
your browser.
Operation Reference
| Operation | Purpose | Example |
|---|---|---|
| add | Insert a value at a path. For arrays, shifts subsequent elements. | {"op":"add","path":"/foo","value":1} |
| remove | Remove a value at a path. | {"op":"remove","path":"/foo"} |
| replace | Replace a value (equivalent to remove + add at the same path). | {"op":"replace","path":"/foo","value":2} |
| move | Move a value from one path to another. | {"op":"move","from":"/a","path":"/b"} |
| copy | Copy a value from one path to another — original stays. | {"op":"copy","from":"/a","path":"/b"} |
| test | Assert a value at a path — fails the whole patch if not equal. | {"op":"test","path":"/foo","value":1} |
Paths follow JSON Pointer (RFC 6901) syntax: /user/name, /items/0, /items/- (append). Use ~0 for literal ~ and ~1 for literal /.
How to Use the JSON Patch Builder
- Paste your Source JSON on the left, or click Sample to load an example.
- Edit the Target JSON on the right — or click Copy source → target to start from an identical doc and edit only what changes.
- The generated patch appears below as a JSON array of operations. The colored chips show which op types are included.
- Toggle Detect move to combine matching
remove+addpairs intomoveops (object keys only). - Toggle Detect copy when a new value matches an existing one — the builder uses
copyinstead of duplicating the value. - Toggle Emit test ops to insert a
testbefore every modifying op — yields a safer patch that refuses to run on a drifted document. - Use Apply-Patch Verification as a real-time sanity check: it applies the patch to the source and shows whether it matches the target.
- Click Copy to grab the patch JSON for your API request, test fixture, or migration script.
Common Use Cases
- Build PATCH request bodies for REST APIs that accept
application/json-patch+json. - Generate Kubernetes resource updates (
kubectl patch --type=json). - Craft test fixtures for code that consumes JSON Patches — verify operations apply correctly.
- Diff two snapshots of configuration files or feature flags for audit and review.
- Convert "before/after" JSON examples into reusable migration scripts.
- Document API changes in pull request descriptions by attaching a minimal patch instead of full diffs.
Frequently Asked Questions
What is JSON Patch?
JSON Patch is an IETF standard (RFC 6902) for describing partial modifications to a JSON document as a sequence of operations. It is supported by major REST frameworks, Kubernetes, OpenAPI tooling, and dozens of programming languages.
How does this differ from JSON Merge Patch (RFC 7396)?
JSON Merge Patch is a simpler "deep-merge" format that uses null to delete keys and can't express array element insertions, moves, or copies. JSON Patch (this tool) is the more powerful, operation-based standard — ideal for precise updates and atomic test-guarded changes.
Why does the patch sometimes use replace instead of going inside the object?
When one side is a scalar and the other is a container (or types differ), there's no sub-structure to diff — the tool emits a single replace. For two containers of the same type, the diff recurses to keep the patch minimal.
Why doesn't move work inside arrays?
Array indices shift as items are inserted or removed earlier in the array, which makes from ambiguous in a patch sequence. To stay correct, this builder only emits move and copy for object-key changes, where indices don't shift. Array element changes use plain add / remove.
What do the test ops do?
A test op asserts that a value at a given path equals an expected value. If the assertion fails, the entire patch is aborted — useful for safe, "optimistic-concurrency-style" updates that refuse to run on a document that has drifted from your expectations.
How are object keys with slashes or tildes encoded?
JSON Pointer (RFC 6901) reserves / as a separator and ~ as the escape character. Keys containing / become ~1; keys containing ~ become ~0. The builder handles this automatically.
Is my data sent to a server?
No. JSON parsing, diffing, optimization, and apply-patch verification all happen entirely in your browser. Your data never leaves your device, which makes this tool safe for confidential API payloads and internal documents.
Where should I use the generated patch?
Send it as the request body of a PATCH request with Content-Type: application/json-patch+json, pass it to kubectl patch --type=json, or feed it into any RFC 6902 library (fast-json-patch, Python's jsonpatch, .NET's JsonPatchDocument, etc.).
Need a side-by-side JSON diff instead?
If you want a visual line-by-line diff (not a patch), open the JSON Diff tool — colored highlighting of every changed value, 100% client-side.