Diff API FREE

Compare two text or JSON snippets. Unified, context, ndiff, side-by-side HTML, or structured JSON. Zero signup.

Try the interactive UI: /tools/diff

POST /diff/text

Compare two text snippets. Returns a diff in the requested format.

Body (JSON)

FieldTypeDefaultDescription
astringrequiredThe "before" text (max 200,000 chars)
bstringrequiredThe "after" text (max 200,000 chars)
a_labelstring"a"Label shown in diff header
b_labelstring"b"Label shown in diff header
context_linesint3Lines of context (0-20)
ignore_whitespaceboolfalseCollapse whitespace before compare
ignore_caseboolfalseCase-insensitive compare

Query: format

formatReturnsNotes
unified (default)text/plainStandard git diff style
contexttext/plainOld context diff style
ndifftext/plainLine-by-line markers (+/-/?)
htmltext/htmlSide-by-side HTML table (full page)
jsonapplication/jsonSummary + opcodes for programmatic use

Example

curl -X POST https://forge-node.tail2b516d.ts.net/diff/text?format=unified \
  -H 'Content-Type: application/json' \
  -d '{"a":"hello\nworld\n","b":"hello\nthere\n","a_label":"old.txt","b_label":"new.txt"}'

POST /diff/json

Compare two JSON values structurally. Both inputs are canonicalized (sorted keys, fixed indent) and a unified diff is returned, plus a summary.

Body

aobject/arrayRequired
bobject/arrayRequired
sort_keysboolDefault true (recommended)
indentint0-8, default 2

Example

curl -X POST https://forge-node.tail2b516d.ts.net/diff/json \
  -H 'Content-Type: application/json' \
  -d '{"a":{"name":"forge","port":8080},"b":{"name":"forge","port":8081,"tls":true}}'

POST /diff/similarity

Returns just the summary block (added/removed lines, similarity ratio 0-1) without producing a full diff. Same body shape as /diff/text.

GET /health/diff

Service health check. Returns {"status":"ok"}.

Limits

Rate limited at 60 requests/minute per IP. Max input length 200,000 characters per side. No auth required.

Powered by Python's stdlib difflib. Part of the Forge Node API suite — 13 free developer APIs, no signup.