JSON Patch Applier (RFC 6902)
Paste a JSON document and a JSON Patch array to apply the operations in order and see the result, or the exact operation that failed.
Use the tool
Why this tool exists
JSON Patch is used in Kubernetes patches, REST APIs and sync protocols, and a mistake in a path or index fails the whole patch. When a server returns a vague 422 error, you want to run the same patch locally and learn which of ten operations was at fault.
This tool applies add, remove, replace, move, copy and test as defined in RFC 6902. The operations run in sequence on a copy of the document, so your input is not altered, and the error message gives the position, operation and path. A test operation that does not match stops the patch, which is how conditional updates work. It follows the standard, but a particular server may differ in edge cases.
How to use it
- Paste the JSON document into the first box.
- Paste the patch, an array of operations, into the second box.
- Read the patched document, or the error naming the failing operation.
Frequently asked questions
Is the patch applied atomically?
Yes in effect. If any operation fails, you get an error and no partial result, because the patch is applied to a copy and discarded on failure.
What does the dash path segment do?
In an add operation on an array, a trailing dash appends the value at the end. For other operations it is not a valid index and causes an error.
How does the test operation compare values?
It uses deep equality, ignoring key order in objects. If the values differ, the patch stops with a message that the test failed.
Can I move a value into its own child?
No. The RFC forbids it and the tool reports an error. Moving a value to a different parent or a sibling is fine.