JSON Patch Guide: Apply Precise Changes to JSON Documents
2026-05-06 6 min read
JSON Patch (RFC 6902) is a standard format for describing precise edits to JSON documents. Instead of replacing an entire object, a patch specifies exact operations: add, remove, replace, move, copy, test. Our JSON Patch tool lets you design and apply patches interactively.
Patch Operations
| Operation | Syntax | Example |
|---|---|---|
| add | {op: "add", path: "/foo", value: "bar"} | Add a new key or array element |
| remove | {op: "remove", path: "/foo"} | Delete a key or array element |
| replace | {op: "replace", path: "/foo", value: "baz"} | Change an existing value |
| move | {op: "move", from: "/foo", path: "/bar"} | Rename or relocate a key |
| copy | {op: "copy", from: "/foo", path: "/bar"} | Duplicate a value |
| test | {op: "test", path: "/foo", value: "bar"} | Assert a value (fail if mismatch) |
Patch Example
Original JSON
{
"user": {
"name": "Alice",
"email": "alice@example.com"
}
} Patch (array of operations)
[
{"op": "replace", "path": "/user/email", "value": "alice.johnson@example.com"},
{"op": "add", "path": "/user/verified", "value": true}
] Result after applying patch
{
"user": {
"name": "Alice",
"email": "alice.johnson@example.com",
"verified": true
}
} Real-World Applications
- API partial updates (PATCH endpoints return a JSON patch)
- Collaborative editing (operational transform documents)
- Database migrations (apply versioned patches)
- Configuration drift correction (patch to desired state)
Design JSON patches
Specify patch operations and apply them to your JSON.