Skip to content
gohacks.dev
APIs

JSON Patch Tool

Apply an RFC 6902 JSON Patch to a document, generate a patch from two documents, or apply an RFC 7386 merge patch, with clear errors for failing operations.

Free · No sign-up · Your inputs stay in your browser

Input

Apply or generate a JSON Patch

Output

Result

117 characters

A JSON Patch is applied all or nothing: a failing test operation leaves the document untouched, which is how optimistic concurrency is done with PATCH. A merge patch is simpler but cannot set a value to null (null means delete) or change one element of an array. kubectl patch --type=json and --type=merge take these two formats.

Runs in this browser. Nothing you paste is sent to a server.

Which format

A merge patch is just the changed fields as JSON, with null meaning delete; it is easy to write but cannot set a value to null or change one item of an array. A JSON Patch (RFC 6902) is a list of operations addressed by JSON Pointer, and its test operation lets a client say "only if the value is still what I read", which is how optimistic concurrency works over PATCH.

Where you meet them

kubectl patch takes both with --type=json and --type=merge, many REST APIs accept application/json-patch+json, and JSON Pointer paths escape / as ~1 and ~ as ~0.

Share

Frequently asked questions

What does the dash in /tags/- mean?
In JSON Patch, - as the last path segment of an array means the position after the last element, so add appends to the array.
Is a JSON Patch applied atomically?
Per the specification, yes: if any operation fails, none of the changes is applied. This tool follows that rule.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools