deftools.io JSON Tools

JSON Patch Generator

Generate RFC 6902 JSON Patch documents by comparing two JSON objects. Useful for API PATCH requests and partial updates.

About this tool

JSON Patch (RFC 6902) is a standard format for describing partial updates to a JSON document. Instead of sending the entire modified object, you send a list of operations — add, remove, replace, move, copy, and test — each targeting a specific path within the document.

This tool compares two JSON objects and produces the patch that transforms the source into the target. For example, given source {"name":"Alice"} and target {"name":"Bob","age":30}, the generated patch is [{"op":"replace","path":"/name","value":"Bob"},{"op":"add","path":"/age","value":30}].

The Include test ops option wraps destructive changes (replace, remove) with a test operation that asserts the current value matches the source — so the patch fails safely if the document has changed in the meantime.

FAQ

When would I use JSON Patch instead of PUT?

Use JSON Patch (PATCH with content type application/json-patch+json) when you only want to change a few fields in a large document — it sends just the delta instead of the whole object, saving bandwidth and reducing race conditions.

What do the path strings mean?

Paths use JSON Pointer notation (RFC 6901). <code>/name</code> means the "name" key at the root; <code>/tags/0</code> means the first element of the "tags" array; <code>/author/email</code> navigates into nested objects. The <code>~0</code> escape represents a literal <code>~</code> and <code>~1</code> a literal <code>/</code>.

Why does the patch include "test" operations?

A <code>test</code> operation asserts that a value at a given path equals what you expect. If the document has changed since you read it, the test fails and the whole patch is rejected — this is optimistic concurrency control and prevents accidental overwrites.

Are move and copy operations supported?

This tool generates <code>add</code>, <code>remove</code>, and <code>replace</code> operations plus optional <code>test</code> guards. <code>move</code> and <code>copy</code> operations are not generated because detecting them requires semantic analysis (is this value identical by coincidence or intentionally the same object?). The generated patch is functionally equivalent.

How is this different from a visual JSON diff?

A visual diff tool like <a href="/json-diff">JSON Diff</a> highlights added, removed, and changed fields side by side for human review. This tool generates an RFC 6902 patch document — a machine-readable list of operations you can apply with any JSON Patch library. Use JSON Diff to see what changed; use this tool when you need the actual patch to apply.

More json tools

Copied!