Developer Tools

JSON Diff — RFC 6902 Patch Generator

Compare two JSON documents and get a machine-applicable JSON Patch: every add, remove, and replace operation between base and target.

100% browser-side processing — nothing is uploaded

JSON Patch Diff: Generate RFC 6902 operations from base → target. Output updates live as you type — or press Ctrl/Cmd + Enter.

Results update live as you type.
14 lines · 0.29 KB
16 lines · 0.38 KB
1 lines · 0.00 KB

Related tools

How to diff two JSON documents

  • Paste base JSON

    The "before" document goes in the Base panel — the old config, the previous API response.

  • Paste target JSON

    The "after" document goes in the Target panel. Both validate live with error line markers.

  • Read the patch

    The output lists add, remove, and replace operations that transform base into target — apply it with any JSON Patch library.

Why a patch beats a side-by-side diff

A textual diff of two JSON files is noisy — reordered keys, reindented blocks, and trailing commas all light up even when no data changed. A JSON Patch diff compares the parsed data, so formatting differences vanish and only real changes remain: each one an operation with a precise path like /goals/1/target. The output is also executable — every mainstream language has an RFC 6902 library (fast-json-patch in JavaScript, jsonpatch in Python), so the same document that explains a change in a pull request can apply it in a migration script.

How arrays are compared

Array elements are matched by index: element 0 against element 0, and so on, with removals and additions emitted for length differences. That means inserting an item at the front of a list reads as a chain of replaces plus one add — technically correct and fully applicable, just more verbose than a human would write. This generator emits add, remove, and replace; it does not synthesize move or copy operations, which are optional optimizations under the RFC and are never required for a valid patch.

JSON Diff — RFC 6902 Patch Generator FAQ

What format is the output?

RFC 6902 JSON Patch — an array of operations with op, path, and (for add/replace) value fields. Paths use JSON Pointer syntax (RFC 6901), with / and ~ escaped as ~1 and ~0.

How do I apply the patch?

Use any RFC 6902 library: fast-json-patch (JavaScript), jsonpatch (Python), JsonPatch in .NET, and equivalents elsewhere. Apply the operations to the base document to reproduce the target.

Does key order affect the diff?

No. Documents are compared as parsed data, so key order and formatting are ignored. Two differently ordered but equal objects produce an empty patch.

Why does inserting one array item produce many operations?

Arrays are diffed by index, so a front-insertion shifts every element and reads as replaces plus an add. The patch is still correct and minimal patches are not required by the RFC.

Can I diff API responses with secrets in them?

Yes — comparison runs entirely in your browser. Neither document is uploaded or stored anywhere.