Tool guide
About this tool.
A JSON Patch (RFC 6902) is a JSON array of operations that turns one document into another. Each operation has an op and a JSON Pointer path such as /users/0/name; add, replace and test also carry a value, and move and copy read a from pointer.
In a pointer, ~1 stands for / and ~0 for ~, so the key "a/b" is written /a~1b. An empty path is the whole document, and - after an array path means the end of that array.
Generate compares the original with the target the way JSON Diff does: objects by key, arrays by index, numbers by value. An added value becomes add, a removed one remove and a changed one replace. Array removals are written from the highest index down, so the patch applies in order.
Apply runs add, remove, replace, move, copy and test on a parser that keeps number spelling and key order. If any operation fails, the whole patch stops with an error naming the operation, and nothing is partly applied.
Choose Generate patch or Apply patch.
Paste the original JSON as the main input.
To generate, paste the Target JSON; to apply, paste the JSON Patch array.
Run the tool, then copy the result or save it as patch.json or patched.json.
- {"a":1} to {"a":2} → [{"op":"replace","path":"/a","value":2}].
- [1,2,3] to [1] → remove /2, then remove /1.
- {"a/b":1} to {} → [{"op":"remove","path":"/a~1b"}].
- Apply [{"op":"add","path":"/tags/-","value":"x"}] to {"tags":[]} → {"tags": ["x"]}.
- Apply [{"op":"test","path":"/n","value":1e0}] to {"n":1.0} → passes, because numbers compare by value.
- Processing is local; nothing is uploaded.
- Limits: 5,000,000 UTF-16 units per document; generate: 100,000 values per side; apply: 10,000 operations, 128 nesting levels and 5,000,000 copied characters in total.
- Arrays are compared by index, so an insert or removal near the front of an array becomes replace operations plus an add or remove at the end. There is no minimal array diff.
- A duplicate key in a JSON document keeps its last value, as JSON.parse does, and the summary names the key and line. A duplicate key in the patch operation list is rejected, because it is unclear which operation was meant.
- Unknown members of an operation are ignored, as RFC 6902 says. JSON Merge Patch (RFC 7386) is not supported.