Diff two JSON documents
Exactjson_diffDeterministic and authoritative — the canonical answer for this input.
Structural diff of two JSON documents. Returns the paths added in b, removed from a, and the leaves that changed (with before/after values), plus an equal flag.
Parameters
astringrequiredThe first ('before') JSON document.
bstringrequiredThe second ('after') JSON document.
separatorstringoptionalPath separator in the reported paths.
Call it
curl -X POST https://api.snipget.ai/v1/json/diff \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{"a":"{\"name\": \"Ada\", \"age\": 36}","b":"{\"name\": \"Ada\", \"age\": 37, \"city\": \"London\"}"}'Example response
{
"is_valid": true,
"equal": false,
"added": [
"city"
],
"removed": [],
"changed": [
{
"path": "age",
"from_value": 36,
"to_value": 37
}
]
}FAQ
Why use this instead of eyeballing two versions?
Spotting what actually changed between two JSON blobs by eye is slow and easy to get wrong, especially when keys are reordered or nested. This walks both documents and tells you exactly what was added, removed, and changed, down to the specific path.
Is the result reliable?
Yes. This is an exact, deterministic comparison, so the same two inputs always give the same answer. It is the canonical diff, not a guess.
How does it treat arrays?
Arrays are compared position by position. Items only in the longer list show as added or removed by their index, and a value that differs at the same index shows as changed. It does not try to detect that an item simply moved.
Does key order matter?
No. Object keys are matched by name, so reordering keys between the two documents does not show up as a change.
What if one side is not valid JSON?
You get a result with confidence 0 and a reason saying the JSON was invalid, not a crash or an error page. Fix the input and resend.