JSON Patch apply and generate
Apply or generate RFC 6902 JSON Patch, or apply an RFC 7396 merge patch.
Runs in your browser. Your input is not uploaded.
Loading the tool…
What it does, how to use it, and questions
What it does
JSON Patch (RFC 6902) is a list of operations (add, remove, replace, move, copy, test) that change a JSON document. JSON Merge Patch (RFC 7396) is a partial object where null deletes a key.
This page applies a patch, generates one from before/after documents, or applies a merge patch. Errors name the operation index and path.
How to use it
- Choose Apply, Generate or Merge patch.
- Paste the document and the patch (or before and after).
- Copy the result.
Things to watch for
- Array items are addressed by index. Inserting at the start shifts later indexes.
- Generate uses a structural walk; it may emit a whole-array replace when lengths differ.
Questions
- What is a JSON Pointer?
- A path such as
/users/0/name.~and/in keys are escaped as~0and~1. - Does this talk to a server?
- No. Patching runs in this page.
- Can I export a patch from JSON diff?
- Use Generate with the two documents. The JSON diff page lists paths in a human form.
- What does test do?
testfails the whole patch if the value at that path is not equal to the given value.