Text diff API: what changed between two versions

A text diff API takes an old and a new text and returns what was added, removed and kept, often as a unified diff like git's. Python's difflib and git diff --no-index do this for free on your machine. Our Text Diff API compares by line, word or character and returns the changes, counts, a 0 to 1 similarity score and a unified diff for $0.002 per call.

Try it free Text Diff API — line, word or character, $0.002 · $0.002 / call

Free ways to diff

# any two files, no repository needed
git diff --no-index old.txt new.txt

# Python standard library
import difflib
old = open("old.txt").read().splitlines(keepends=True)
new = open("new.txt").read().splitlines(keepends=True)
print("".join(difflib.unified_diff(old, new, "old", "new")))
print(difflib.SequenceMatcher(None, "".join(old), "".join(new)).ratio())

Line, word or character

Word mode ignores spacing changes and counts words, so a re-wrapped paragraph with one new word shows as one change, not a whole new paragraph.

ModeUse it forMax per text
lineCode, config files, lists200,000 characters
wordProse: contracts, articles, AI rewrites200,000 characters
charShort strings: names, SKUs, typos20,000 characters

The API call

It uses the jsdiff library (Myers algorithm). context sets how many unchanged lines surround each change in the unified diff, 0 to 20, default 3. The unified diff is always line by line, whatever the mode.

curl -i -X POST https://iamai.markets/api/x402/services/NVVGt1zqlG3C \
  -H "Content-Type: application/json" \
  -d '{"old": "apples 3\nbread 1\nmilk 2\n", "new": "apples 3\nbread 2\nmilk 2\neggs 12\n", "mode": "line"}'

# result: identical: false, counts {added: 2, removed: 1, unchanged: 2},
#   similarity, changes [...], unified_diff "--- old +++ new @@ ..."

Where an API helps

Limits

Paid per call with x402 in USDC on Base; 5 free tries a day on the listing page.

The product

Questions

What does the similarity score mean?

Twice the unchanged units divided by the total in both texts, from 0 (nothing shared) to 1 (identical).

Can it compare two web pages?

Get each page as text or Markdown first, with a page reader, then diff the two texts.

Is it the same as git diff?

The unified_diff output uses the same format, so patch tools and diff viewers can read it.

Related

Updated 2026-12-02