JSON Patch (RFC 6902)
Also called RFC 6902
JSON Patch (RFC 6902) is a format that describes changes to a JSON document as an array of operations, like {"op": "replace", "path": "/name", "value": "Ada"}. Each operation has an op, which is add, remove, replace, move, copy or test, and a JSON Pointer path. It is sent with HTTP PATCH and the media type application/json-patch+json, and the test operation can guard against concurrent edits.
In more detail
JSON Patch is a format for describing changes to a JSON document, defined in RFC 6902. A patch is an array of operations, applied in order. If any operation fails, the whole patch fails.
Each operation has an op and a path, which is a JSON Pointer. The six ops are add, remove, replace, move, copy and test. move and copy also take a from pointer, and add, replace and test take a value. test checks that a value is what you expect, which guards against applying a patch to a document that changed.
APIs accept JSON Patch with the HTTP PATCH method and the media type application/json-patch+json. Unlike JSON Merge Patch, it can change single array elements and set a value to null, at the cost of being more verbose.
Example
[
{ "op": "test", "path": "/version", "value": 3 },
{ "op": "replace", "path": "/name", "value": "Ada King" },
{ "op": "add", "path": "/roles/-", "value": "owner" },
{ "op": "remove", "path": "/legacyId" }
]Try it
Learn more in the guide How to compare two JSON files (JSON diff).
← Back to JSON Patch (RFC 6902) in the JSON glossaryUpdated 2026-10-01