Text Diff

Compare two texts and get a unified diff with change summary.

POST 1 credit /v1/diff
curl -X POST "https://devtools.toolkitapi.io/v1/diff" \
  -H "Content-Type: application/json" \
  -d '{"a": "hello world\nfoo bar", "b": "hello world\nfoo baz"}'
import httpx

resp = httpx.post(
    "https://devtools.toolkitapi.io/v1/diff",
    json={"a": "hello world\nfoo bar", "b": "hello world\nfoo baz"},
)
print(resp.json())
const resp = await fetch("https://devtools.toolkitapi.io/v1/diff", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"a": "hello world\nfoo bar", "b": "hello world\nfoo baz"}),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "unified_diff": "--- a\n+++ b\n@@ -1,2 +1,2 @@\n hello world\n-foo bar\n+foo baz\n",
  "summary": {
    "lines_added": 1,
    "lines_removed": 1
  }
}

Try It Live

Live Demo

Description

Compare two texts and get a unified diff with change summary.

How to Use

1

1. Send a POST request with `a` (original text) and `b` (modified text).

2

2. The `unified_diff` field contains the full diff output. The `summary` gives line-level change counts.

About This Tool

Text Diff compares two text inputs and produces a unified diff output (the same format used by `diff -u` and Git). The summary tells you exactly how many lines were added and removed.

Why Use This Tool

Frequently Asked Questions

What diff format is used?
Standard unified diff format, identical to `diff -u` or `git diff`. Lines prefixed with `+` are additions, `-` are removals, and ` ` (space) are context.

Start using Text Diff now

Get your free API key and make your first request in under a minute.