JSON Diff

Compare two JSON objects and get an RFC 6902 JSON Patch of the differences.

POST 1 credit /v1/json-diff
curl -X POST "https://devtools.toolkitapi.io/v1/json-diff" \
  -H "Content-Type: application/json" \
  -d '{"a": {"name": "Alice", "age": 30}, "b": {"name": "Alice", "age": 31, "city": "NYC"}}'
import httpx

resp = httpx.post(
    "https://devtools.toolkitapi.io/v1/json-diff",
    json={"a": {"name": "Alice", "age": 30}, "b": {"name": "Alice", "age": 31, "city": "NYC"}},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/json-diff", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"a": {"name": "Alice", "age": 30}, "b": {"name": "Alice", "age": 31, "city": "NYC"}}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "patch": [
    {"op": "replace", "path": "/age", "value": 31},
    {"op": "add", "path": "/city", "value": "NYC"}
  ],
  "summary": {
    "added": 1,
    "removed": 0,
    "changed": 1,
    "total": 2
  }
}

Try It Live

Live Demo

Description

Compare two JSON objects and get an RFC 6902 JSON Patch of the differences.

How to Use

1

1. Send a POST request with `a` (the original object) and `b` (the modified object).

2

2. The response contains a `patch` array with RFC 6902 operations (`add`, `remove`, `replace`) and a `summary` with counts.

3

3. Apply the patch to `a` to reproduce `b`, or use the summary to gauge the scope of changes.

About This Tool

JSON Diff compares two JSON objects and produces an RFC 6902-style JSON Patch describing every difference. It recursively walks both objects, detecting added keys, removed keys, and changed values — including nested objects and arrays.

The summary gives you a quick overview of how many fields were added, removed, or changed.

Why Use This Tool

Frequently Asked Questions

Does it handle nested objects?
Yes. The diff recurses into nested objects and arrays, producing JSON Pointer paths like `/address/city` or `/items/0/name`.
Is the patch output compatible with RFC 6902?
The output follows RFC 6902 structure. The operations are `add`, `remove`, and `replace` with standard JSON Pointer paths.
Can I compare arrays?
Yes. Arrays are compared element-by-element by index. Elements added beyond the original array length appear as `add` operations.

Start using JSON Diff now

Get your free API key and make your first request in under a minute.