JSON Patch Generator & Applier
Generate a standard RFC 6902 JSON Patch between two documents, or apply a patch to a document. Supports add, remove, replace, move, copy, and test operations â the same format used by REST PATCH requests and Kubernetes.
Features
𩹠Standards-Compliant
- Generates minimal add/remove/replace patches
- Applies add, remove, replace, move, copy, test
- Correct RFC 6901 JSON Pointer escaping (
~0/~1) - Array append via the
"-"path segment
⥠Privacy-First
- All computation happens in your browser
- No data ever sent to a server
testoperation failures are reported clearly- Download or copy the result instantly
đ Real-World Use
- Debug PATCH request bodies for REST APIs
- Inspect Kubernetes strategic merge patches
- Pairs with our JSON Diff tool for visual comparison
- Verify a patch round-trips to the expected document
JSON Patch Guide
JSON Patch (RFC 6902) is a standard format for describing changes to a JSON document as a sequence of operations â add, remove, replace, move, copy, and test â each targeting a location via a JSON Pointer (RFC 6901) path like /user/tags/0. It's the format used by HTTP PATCH requests in many REST APIs and by Kubernetes for partial resource updates.
Frequently Asked Questions
How is this different from JSON Diff?
JSON Diff is for humans â a visual, side-by-side comparison. JSON Patch produces a machine-readable list of operations conforming to RFC 6902 that another system can apply directly, e.g. as the body of an HTTP PATCH request.
What does the test operation do?
A test operation checks that a value at a given path matches an expected value before continuing. If the check fails, applying the patch stops with an error â useful for optimistic concurrency control.
How do I append to an array?
Use "-" as the final path segment, e.g. {"op": "add", "path": "/items/-", "value": "new"} â this appends to the end of the array per the RFC 6901 spec.
Using JSON Patch in real APIs
JSON Patch lets a client send only the changes to a resource instead of the whole document, which saves bandwidth and avoids overwriting fields edited by someone else. It is widely supported, for example by the Kubernetes API.
Tips and common pitfalls
- Send patches with the HTTP
PATCHmethod and theapplication/json-patch+jsoncontent type. - Put a
testoperation first to check a value before changing it. If the test fails, the whole patch is rejected, which gives you optimistic concurrency. - Paths use JSON Pointer syntax. Escape
~as~0and/as~1inside key names. - Operations run in order, and array indexes shift after an add or remove, so generate patches with a tool rather than by hand.
More questions
Is a JSON Patch applied atomically?
Yes. RFC 6902 requires that if any operation fails, the document is left unchanged.
When is JSON Merge Patch the better choice?
When you only set and remove object fields. Merge Patch is simpler to write but cannot edit individual array items or set a value to null. See our JSON Merge Patch tool.