JSON diff

Compare two JSON documents and get the differences as a JSON Patch (RFC 6902).

Input

The original JSON.
The changed JSON.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/json-diff \
  -H 'Content-Type: application/json' \
  -d '{"input":{"before":"{\"a\":1,\"b\":[1,2],\"c\":true}","after":"{\"a\":2,\"b\":[1,2,3]}"}}'
import json, urllib.request

body = {'input': {'before': '{"a":1,"b":[1,2],"c":true}', 'after': '{"a":2,"b":[1,2,3]}'}}
request = urllib.request.Request("https://setget.net/v1/tools/json-diff", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/json-diff", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"before":"{\"a\":1,\"b\":[1,2],\"c\":true}","after":"{\"a\":2,\"b\":[1,2,3]}"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "json-diff",
  "input": {
    "before": "{\"a\":1,\"b\":[1,2],\"c\":true}",
    "after": "{\"a\":2,\"b\":[1,2,3]}"
  }
}
{
  "input": {
    "before": "{\"a\":1,\"b\":[1,2],\"c\":true}",
    "after": "{\"a\":2,\"b\":[1,2,3]}"
  }
}

Endpoint: POST /v1/tools/json-diff. Over MCP: run_tool with slug: "json-diff". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
before string yes The original JSON.
after string yes The changed JSON.

Example

Input
{
  "before": "{\"a\":1,\"b\":[1,2],\"c\":true}",
  "after": "{\"a\":2,\"b\":[1,2,3]}"
}
Result
{
  "equal": false,
  "patch": [
    {
      "op": "remove",
      "path": "/c"
    },
    {
      "op": "replace",
      "path": "/a",
      "value": 2
    },
    {
      "op": "add",
      "path": "/b/-",
      "value": 3
    }
  ],
  "summary": {
    "add": 1,
    "remove": 1,
    "replace": 1
  }
}

Questions

Does key order matter?
No. Objects are compared by key, so reordering keys is not a difference.
How are arrays compared?
Position by position. An item inserted at the start shows as changes to every later position.