CoreJSON

JSON Patch

This tool works with JSON Patch per RFC 6902. In generate mode it compares two JSON documents and outputs a sequence of operations that contains only the differences (add / remove / replace / move / copy / test). In apply mode it applies a patch to a target document and returns the modified result. Everything runs locally in your browser.

Open in the workbench Runs locally · nothing is uploaded

How to use it

  1. 1

    Pick a mode

    Switch between "Generate patch" and "Apply patch" at the top.

  2. 2

    Generate: paste both documents

    Put the original on the left and the target on the right; the RFC 6902 operation sequence is generated after you pause typing.

  3. 3

    Apply: paste the target and the patch

    Put the target data on the left and the patch array on the right; the tool applies each operation and outputs the result.

  4. 4

    Copy the result

    Copy the generated patch or the applied result in one click to use it in an API or script.

Key features

Standard RFC 6902

The operation sequence follows the add, remove, replace, move, copy and test spec, so it works with any JSON Patch-capable API.

Selectable array strategy

When generating you can compare arrays index by index (minimal changes) or replace the array wholesale (shorter patch).

JSON Pointer escaping

Paths follow the RFC 6901 ~0 / ~1 escaping rules, so keys containing slashes or tildes are located correctly.

Per-operation errors

When applying fails it states which operation number and path failed and why (such as an out-of-range array index or a failing test assertion).

Deterministic operation order

Operations are emitted in a stable order so the same pair of documents always produces the same patch, easy to review and diff.

Local computation

Generation and application run in a Web Worker and the data is never uploaded.

Common errors & troubleshooting

  • ! Generation matches objects by key name and arrays by index by default. Inserting into the middle of an array can produce many operations, so switch to "replace whole array" when needed.
  • ! In apply mode, test operations act as assertions; a mismatch between the actual and expected values makes the apply fail, which is the behaviour the spec requires.
  • ! A patch is a JSON array where each item needs at least an op and a path field.
  • ! Because replace and remove require the target path to exist, use add when you are creating a new node.

Frequently asked questions

Can the generated patch be used directly with an API?

Yes. The output follows RFC 6902 and can be sent to a server that supports JSON Patch (Content-Type: application/json-patch+json).

Why is the patch for an array so long?

By default arrays are compared index by index, so inserting or removing in the middle shifts every later index. Switching to "replace whole array" covers the entire array with a single replace operation.

What if applying a patch reports "path does not exist"?

replace and remove require the target path to already exist; if the node is missing, use add instead. Check that the path matches the actual data.

Is my data uploaded?

No. Generation and application both happen locally in your browser, which you can confirm in the Network panel.

Related tools