Compare two text or JSON snippets. Unified, context, ndiff, side-by-side HTML, or structured JSON. Zero signup.
Try the interactive UI: /tools/diff
Compare two text snippets. Returns a diff in the requested format.
| Field | Type | Default | Description |
|---|---|---|---|
a | string | required | The "before" text (max 200,000 chars) |
b | string | required | The "after" text (max 200,000 chars) |
a_label | string | "a" | Label shown in diff header |
b_label | string | "b" | Label shown in diff header |
context_lines | int | 3 | Lines of context (0-20) |
ignore_whitespace | bool | false | Collapse whitespace before compare |
ignore_case | bool | false | Case-insensitive compare |
| format | Returns | Notes |
|---|---|---|
unified (default) | text/plain | Standard git diff style |
context | text/plain | Old context diff style |
ndiff | text/plain | Line-by-line markers (+/-/?) |
html | text/html | Side-by-side HTML table (full page) |
json | application/json | Summary + opcodes for programmatic use |
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"}'
Compare two JSON values structurally. Both inputs are canonicalized (sorted keys, fixed indent) and a unified diff is returned, plus a summary.
a | object/array | Required |
b | object/array | Required |
sort_keys | bool | Default true (recommended) |
indent | int | 0-8, default 2 |
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}}'
Returns just the summary block (added/removed lines, similarity ratio 0-1) without producing a full diff. Same body shape as /diff/text.
Service health check. Returns {"status":"ok"}.
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.