Text diff
Compare two texts line by line and get a unified diff with counts of added and removed lines.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/diff \
-H 'Content-Type: application/json' \
-d '{"input":{"before":"apple\nbanana\ncherry\n","after":"apple\nblueberry\ncherry\ndate\n"}}'
import json, urllib.request
body = {'input': {'before': 'apple\nbanana\ncherry\n', 'after': 'apple\nblueberry\ncherry\ndate\n'}}
request = urllib.request.Request("https://setget.net/v1/tools/diff", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/diff", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"before":"apple\nbanana\ncherry\n","after":"apple\nblueberry\ncherry\ndate\n"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "diff",
"input": {
"before": "apple\nbanana\ncherry\n",
"after": "apple\nblueberry\ncherry\ndate\n"
}
}
{
"input": {
"before": "apple\nbanana\ncherry\n",
"after": "apple\nblueberry\ncherry\ndate\n"
}
}
Endpoint: POST /v1/tools/diff. Over MCP: run_tool with slug: "diff".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
before |
string | yes | The original text. |
after |
string | yes | The changed text. |
context |
integer | no | Unchanged lines to show around each change. Default: 3. From 0 to 1000. |
Examples
Input
{
"before": "apple\nbanana\ncherry\n",
"after": "apple\nblueberry\ncherry\ndate\n"
}Result
{
"text": "--- before\n+++ after\n@@ -1,3 +1,4 @@\n apple\n-banana\n+blueberry\n cherry\n+date\n",
"added": 2,
"removed": 1,
"hunks": 1,
"equal": false
}Identical texts
Input
{
"before": "same\n",
"after": "same\n"
}Result
{
"text": "",
"added": 0,
"removed": 0,
"hunks": 0,
"equal": true
}Questions
- What does "\ No newline at end of file" mean?
- The line above it is the last line of a text that does not end with a line break. The marker lets a patch tool rebuild the text exactly.
- Can I apply the result with patch or git apply?
- Yes. The output is a standard unified diff. The file names are "before" and "after".
- Are Windows line endings a difference?
- No. Windows (CRLF) line endings are treated as plain line breaks in both texts.
Related tools
- Apply a patchApply a unified diff to a text and get the patched result, with clear errors when a hunk does not fit.
patch-apply - JSON diffCompare two JSON documents and get the differences as a JSON Patch (RFC 6902).
json-diff - Levenshtein distanceCount the single-character edits needed to turn one string into another, with a similarity ratio.
levenshtein - Case converterConvert text between lower, UPPER, Title, Sentence, camelCase, PascalCase, snake_case, kebab-case and more.
case-convert - Escape and unescape textEscape or unescape text for HTML, URLs, JSON strings, shell commands, regular expressions and CSV fields.
escape-unescape - Extract emails and URLsPull every email address and web link out of a text, and optionally IPv4 addresses and hashtags.
extract-emails-urls