Compare text
Two versions of a config file, a changelog, or a customer message can look identical until the one character that broke everything turns out to be a curly quote where a straight one belonged. This endpoint takes two pieces of text and returns exactly what changed between them at the granularity you choose, from whole lines down to single characters.
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
The everyday problem behind it
Diffing text sounds like a solved problem because source code editors do it constantly, but most of that tooling is built into an editor or a version control system and is not something a backend service can just call. Meanwhile the need for a diff shows up everywhere outside of code too: comparing two drafts of an email template, checking whether a scraped web page actually changed since yesterday, or verifying that a translated string still matches its source after an edit. The text diff api brings that same capability to any text, from any source, on demand.
Three granularities, one endpoint
You choose how fine the comparison should be. Line-level diffing is the familiar view from version control, useful for structured text like code or config files where a whole line changing is the meaningful unit. Word-level diffing is better suited to prose, showing exactly which words were added, removed or replaced inside an otherwise unchanged sentence. Character-level diffing goes further still, catching a single typo, a swapped digit, or a stray punctuation mark that word-level comparison would gloss over as one changed word.
How the request and pricing work
POST both pieces of text to /data/diff and the call returns a task_id immediately, with the structured diff delivered to your signed webhook or through a signed link valid for 24 hours once the comparison finishes. Pricing is a flat $0.002 per request regardless of which granularity you request, and a job that fails after three retries is never billed.
The algorithm underneath, briefly
Computing a good diff is a genuine computer science problem, not just a string comparison: the goal is finding the shortest set of edits that turns one text into the other, and the classic approach traces back to the longest common subsequence algorithms developed for exactly this purpose decades ago and still used, in refined form, by every serious diff tool today. Getting it right matters because a bad diff algorithm reports far more changes than actually happened, burying the real edit in noise.
Where it belongs in automation
Because output is structured and delivered asynchronously, diffing fits naturally into content approval workflows, change-monitoring jobs that watch a source for edits, translation QA pipelines, and support tools that need to show a customer exactly what changed in their account settings. Access requires prepaid balance, keeping the endpoint fast and abuse-free. This endpoint is live now.
What you can do with it
Web page change monitoring
A price-tracking tool diffs today's scraped page text against yesterday's snapshot to detect exactly which lines changed, ignoring pages that reloaded with no real content change.
Translation quality checks
A localization team diffs a translated string against its previous version after a source edit, confirming the translator updated the same portion the source changed.
Editorial review
A content team diffs two drafts of an article at the word level to see exactly what an editor changed, without wading through a wall of line-level noise from reformatted paragraphs.
Configuration drift detection
A DevOps pipeline diffs a deployed configuration file against its source-controlled version at line level to catch manual changes made directly on a server.
FAQ
How do I diff two texts with an API?
POST both texts to /data/diff. The text diff api returns a task_id right away and delivers the structured differences to your webhook or a signed link once the comparison finishes.
Is this API free to use?
The tool above runs free in your browser. The API is paid — each call draws from your prepaid ForHosting KIT balance: top up from $10.00 (it never expires), pay each request's published price, and a call with no balance returns HTTP 402. No subscription, no tokens, and a failed task is never charged.
What granularities does it support?
You can request line-level, word-level or character-level diffing depending on whether you need a high-level overview or the exact characters that changed.
Can it compare very large documents?
Yes, because processing is asynchronous the endpoint can handle full-length documents without holding your request thread open while the diff computes.
Does it work on plain text only, or also code?
It works on any plain text, including source code, configuration files, and prose, with line-level diffing typically preferred for structured formats like code.
Can I run diffs on many text pairs in bulk?
Yes, each pair is submitted as its own request and processed independently, so a batch of comparisons can run in parallel with results delivered by webhook as each finishes.
Is the Text Diff API live now?
Yes, this endpoint is live today at the published price of $0.002 per request.
What happens to my text after comparing it?
Both submitted texts and the resulting diff are deleted after the retention window and are never used for training. Delivery is by signed webhook or a signed link valid for 24 hours.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, and soon from our app, email and Telegram.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/data/diff \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"…"}'const res = await fetch("https://api.kit.forhosting.com/data/diff", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"input": "…"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/data/diff",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"input": "…"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/data/diff", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"input":"…"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"input":"…"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/data/diff", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"input": "…"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "data.diff",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_mb | 25 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |