JSON Patch (RFC 6902)

Generate add / remove / replace patches between two JSON documents and apply them safely.

[
  {
    "op": "replace",
    "path": "/name",
    "value": "Ada Lovelace"
  },
  {
    "op": "remove",
    "path": "/age"
  },
  {
    "op": "add",
    "path": "/address/country",
    "value": "UK"
  },
  {
    "op": "add",
    "path": "/tags/2",
    "value": "founder"
  },
  {
    "op": "add",
    "path": "/active",
    "value": true
  }
]

About JSON Patch (RFC 6902)

  • Supported ops in this tool: add, remove, replace.
  • Paths use JSON Pointer (RFC 6901): /address/city, /tags/0, or /tags/- to append.
  • Tokens with / or ~ are escaped as ~1 and ~0.

About JSON Patch (RFC 6902)

JSON Patch generates the operations that turn one JSON document into another, following RFC 6902. The output is an array of operations — `add`, `remove`, `replace`, `move`, `copy`, `test` — each with a JSON Pointer path. You can also paste an existing patch and apply it to a source document to produce the target.

This is the machine-readable counterpart of JSON Diff. Where Diff produces a human-readable summary of what changed, Patch produces a compact, executable list of edits — exactly what you send to a REST API that supports HTTP `PATCH`, what you persist as a CRDT-friendly delta, or what you apply later to reconstruct the modified document. Patches generated by this tool are deterministic: the same pair of inputs always produces the same operation list, so they round-trip cleanly through storage. Use Diff when humans need to read the result; use Patch when machines need to apply it.

Examples

Input
A: {"name":"Ada","born":1815}
B: {"name":"Ada","born":1815,"died":1852}
Output
[{"op":"add","path":"/died","value":1852}]

A single add operation. Apply this patch to A and the output equals B.

Frequently asked questions

How is this different from JSON Diff?

Diff produces a human-readable list of additions, removals, and changes. Patch produces an RFC 6902 operation list designed to be applied programmatically. Same comparison underneath, different consumer.

What does 'JSON Pointer' mean in the path?

JSON Pointer is RFC 6901 — a slash-separated path expression. `/users/0/name` means: in the root, follow the `users` key, then index 0, then the `name` key. The tool generates these automatically.

Why are some patches longer than I expect?

Because the tool defaults to minimal `add`, `remove`, and `replace` operations. To collapse adjacent changes into `move` or `copy`, enable the prefer-move/copy option, which produces shorter patches at the cost of more compute.

Can I apply a patch that I wrote by hand?

Yes. Switch to apply mode, paste the source document and the patch, and the tool emits the result with any `test` operations enforced.