Free, browser-based utilities for everyday developer workflows

Generate JSON Patch from two JSON files

When you have a “before” and “after” JSON document, you can generate the minimal JSON Patch (RFC 6902) that transforms one into the other — useful for building PATCH request bodies and audit trails.

Open this example in JSON Patch & Pointer

Open the tool, then paste the sample input below. Everything runs locally in your browser.

Open this example in JSON Patch & Pointer →

The problem

Hand-writing a patch is error-prone. Instead, diff the two documents and let the tool emit add, remove, and replace operations. Then apply the patch back to the original to verify it reproduces the target exactly.

Sample input

Before
{
  "id": 101,
  "name": "Asha",
  "status": "inactive"
}
After
{
  "id": 101,
  "name": "Asha",
  "status": "active",
  "role": "admin"
}

Expected output

Generated JSON Patch
[
  { "op": "replace", "path": "/status", "value": "active" },
  { "op": "add", "path": "/role", "value": "admin" }
]

status changed, so it becomes a replace; role is new, so it becomes an add. Object key order is not treated as a change.

How to do it

  1. Paste the original JSON as the source document.
  2. Paste the updated JSON as the target document.
  3. Generate the patch / inspect the computed difference.
  4. Review each operation, especially around arrays.
  5. Apply the patch to the source to confirm it reproduces the target.

Common mistakes

  • Treating reordered object keys as a real change — they are not in JSON.
  • Assuming array edits are clean: index-based patches can be surprising after inserts.
  • Shipping a generated patch without applying and validating it first.
  • Not confirming that remove/replace target paths exist.

Related tools

Related guides

FAQ

Can I generate JSON Patch from two JSON files?

Yes. Paste the original and updated documents and the tool computes the add/remove/replace operations that turn one into the other.

Why are arrays hard to patch?

Arrays are positional. Inserting or reordering elements can produce many index-based operations, and a naive diff may not match how your API expects arrays to change.

Should I validate the generated patch?

Yes. Apply it back to the original and confirm the result equals your target before using it in production.

Can I use generated JSON Patch in an API PATCH request?

Yes, with Content-Type application/json-patch+json, provided the endpoint accepts RFC 6902 patches.

Is JSON Patch reversible?

Only if you also keep the original values. A replace records the new value, not the old one, so you need the source document (or a rollback patch) to undo it.

Generating and applying patches happens locally in your browser. No documents leave your device.

Explore more JSON and API contract tools

Schema validation, JSON Patch, JSON diff and JSONPath testing — grouped in one place.

View the JSON & API contract toolkit →