JSON Patch Builder (RFC 6902)
Developer
RFC 6902 JSON Patch is a wire format for describing changes to a JSON document — useful for PATCH requests, optimistic updates, undo history, and operational transforms. This tool does both directions: paste a source and target JSON, get the minimal patch that converts one to the other; or paste a source and a patch, see the result after applying. The diff uses recursive structural comparison with `~0`/`~1` JSON Pointer escaping for keys with slashes or tildes. The apply side honors all six ops including `test` (assertion fails throw an error), `copy`, and `move`. Useful for testing patches before hitting your server, or working out the right ops by example.
[
{
"op": "replace",
"path": "/age",
"value": 31
},
{
"op": "replace",
"path": "/address/city",
"value": "Busan"
},
{
"op": "remove",
"path": "/address/zip"
},
{
"op": "add",
"path": "/address/country",
"value": "KR"
},
{
"op": "replace",
"path": "/tags/1",
"value": "owner"
},
{
"op": "add",
"path": "/tags/2",
"value": "user"
}
]Pure RFC 6902 — supports add, remove, replace, move, copy, test ops with `~0`/`~1` pointer escaping.
How to use
- Diff mode: paste source and target, see the patch JSON. Edit either side to see how the patch changes.
- Apply mode: paste source and a patch array, see the resulting document. Errors (bad pointer, failed `test`) show inline.
- JSON Pointer syntax: `/foo/0/bar` walks `foo.0.bar`. Escape `/` as `~1`, `~` as `~0`. Trailing `-` in an array path means 'append'.
Frequently asked questions
- Why not just send the new document?
- Bandwidth for one. Concurrency for two: if Alice and Bob both edit a doc, you can merge their patches semantically (`replace /name` is compatible with `add /tags/-`), while two full docs would have to pick a winner. Plus, patches are a precise audit trail of what changed and when.
- Is this the same as JSON Merge Patch (RFC 7396)?
- No. Merge Patch is simpler — you send a partial document where present keys overwrite and `null` deletes. It's easier for humans but loses precision (can't add to an array, can't represent literal `null` values, no atomic test). RFC 6902 (this tool) is the precise wire format. RFC 7396 is the convenience format.
Related tools
JWT Decoder
Decode a JSON Web Token to inspect its header, claims, and expiration.
UUID Generator
Generate random version-4 UUIDs in bulk, with copy.
Hash Generator (SHA)
Generate SHA-1, SHA-256, SHA-384, and SHA-512 hashes from text.
URL Encoder / Decoder
Percent-encode text for URLs, or decode encoded URLs back to text.
Base64 Encoder / Decoder
Encode text to Base64 or decode Base64 back to text, instantly.
JSON Formatter & Validator
Format, beautify, minify, and validate JSON right in your browser.