# Text Diff — AO tool

> Compare two versions of anything and see exactly what changed — side by side, with no size limit and no account. Runs entirely client-side: no upload, no server, no file limits, no sign-up.

Human page: https://abstractobjective.dev/tools/text-diff/
Status: live · Category: text

## Input and output
- In: two blocks of text pasted into the page
- Out: a side-by-side comparison, plus a unified diff you can copy or download as a .patch

## Programmatic use (the AI-facing twin)
All computation happens locally in the page context.

- `window.AODiff.lines(a, b, {ignoreCase, ignoreWhitespace}) -> [{type, a, b, value}]`
  Line-level diff of two strings using Myers' algorithm. type is equal|insert|delete; a and b are zero-based line indices in each input (-1 where the line does not exist on that side).
- `window.AODiff.summarise(ops) -> {added, removed, unchanged, changed, identical}`
  Counts for an edit script.
- `window.AODiff.unified(a, b, opts) -> string`
  A unified diff, the format patch and code review tools understand.

## Notes
- Uses Myers' 1986 O(ND) algorithm, written in engine/diff.mjs. Common prefixes and suffixes are trimmed first, so a one-line change in a twenty-thousand-line document is near-instant.
- The comparison is verified by the property that matters: the edit script must reconstruct both inputs exactly.
- "Ignore case" and "ignore whitespace" affect matching only — the text shown is always your original, unaltered.
- No file-size gate and no account: the incumbents put larger comparisons behind a sign-up because they process them on a server.

## Properties
- Privacy: files never leave the browser tab.
- Limits: none imposed by us; the practical ceiling is your device's memory.
- Cost model: client-side compute — free without caps, sustainably.

---

## What it shows you

Paste two versions of anything — a document before and after edits, a config file that used to work, two AI answers to the same prompt, a contract and its redline — and this page lines them up side by side. Removed lines are marked in red on the left, added lines in green on the right, and a line that was *modified* appears as a single paired row rather than as an unrelated deletion and addition.

Underneath you also get a **unified diff**, the format that `patch`, Git and every code review tool understand. Copy it, or download it as a `.patch` file.

## No sign-up for the big ones

The well-known comparison sites let you paste small snippets freely and then ask you to create an account for anything substantial. That is not arbitrary: they do the comparison on their servers, so a long document costs them memory and processor time, and the account is how they meter it.

This page does the comparison in your browser, so there is nothing to meter. Paste a whole book if you want to. The only limit is your own machine.

It also means the text stays with you, which matters more here than it first appears: the documents people most often need to compare are drafts, contracts, configuration files and code — exactly the things you would not casually hand to a stranger's server to have them counted.

## How the comparison is made

The underlying algorithm is **Myers' diff** (1986), the same approach Git uses. Its useful property is that the work scales with the *size of the difference*, not the size of the documents — so comparing two twenty-thousand-line files that differ by one line is close to instant. Before the algorithm even runs, the identical head and tail of the two texts are trimmed away, which is what makes that case fast rather than merely possible.

Correctness here has a precise definition, and it is the thing worth testing: the list of edits must reconstruct **both** documents exactly — apply the deletions to the result and you get the original back; apply the insertions and you get the changed version. That property is checked against a range of cases including complete rewrites, empty inputs, and pure insertions.

## Ignore case and ignore whitespace

These two switches change what counts as "the same line", which is useful when the real differences are hidden under cosmetic ones — a file reindented, or a document with inconsistent capitalisation.

They affect **matching only**. The text displayed is always exactly what you pasted, never a normalised version of it. A comparison tool that quietly showed you lowercased text would be solving the wrong problem.
