xtract.bot
POST /api/json-diff

Diff two JSON documents and return the set of differences as JSON Patch operations (RFC 6902) or a structured changes array.

Computes the difference between two JSON documents and returns the changes in two forms: - A JSON Patch (RFC 6902) that, applied to the first input, produces the second. Use this for downstream patching. - A structured `changes` array (`{path, op, oldValue, newValue}`) easier to display in a UI. Useful for auditing config changes, building change-log feeds, or implementing a "compare snapshots" feature.

Inputs

NameTypeDefaultDescription
before*stringThe original JSON document, as a string.
after*stringThe new JSON document, as a string.
includeFromValuebooleanfalseAnnotate each replace op with what it replaced (non-standard).

Response

Modes: json. Cache: yes (24h TTL).

Code samples

Built from the trivial-rename example.


curl -X POST https://api.xtract.bot/api/json-diff \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "before": "{\"name\":\"alice\",\"age\":30}",
  "after": "{\"name\":\"alice\",\"age\":31}",
  "includeFromValue": false
}'