Text Diff
Paste an old and a new version of any text (code, config, an API response, two LLM answers) and see which lines were removed (-), added (+) or kept. When a line was edited rather than replaced, the words that changed are highlighted inside it. Options ignore whitespace or letter case. The comparison runs in your browser; neither text is uploaded.
How to use the Text Diff
- Paste the original text into Old and the changed text into New, then press Diff.
- Read the result top to bottom. Unchanged lines start with a space, removed lines with
-, added lines with+. A summary line counts them. - Where a block of removed lines is followed by the same number of added lines, each pair is treated as an edit and the changed words are highlighted.
- Use Swap sides to reverse the direction.
Load example compares a JavaScript function with its TypeScript version. Only the first line differs, so the result is
one removed line, one added line and four unchanged ones (+1 · −1). Inside the edited line nothing from the old text is
removed; the added words are the three : number annotations.
How the diff is computed
The tool finds the longest common subsequence (LCS) of lines: the largest set of lines that appear in both texts in the
same order. Everything outside that set is a removal from the old text or an addition in the new one. This is the same kind of result
git diff and diff -u give, although those tools use other algorithms (Myers, patience) that can group a change
differently when lines repeat. When a change could be shown either way, this tool lists the removals before the additions.
Lines that match at the very start and end are set aside first, so a long file with a small edit in the middle is fast. The remaining
middle part is compared with a table of size old lines × new lines; above 4,000,000 cells the tool stops and says so rather than freezing
the tab. For bigger comparisons, git diff --no-index old.txt new.txt on your machine has no such limit.
The word-level pass runs the same LCS on the tokens of an edited line pair: words, runs of spaces and single punctuation marks. Changing
return a + b; to return a - b; highlights only the -.
Ignore whitespace collapses runs of spaces and tabs to one space and trims each line before comparing, so a re-indented
block counts as unchanged: return 1; and return 1; match. It never removes a
space between words, so a b and ab still differ, and it works line by line. Ignore case compares
lowercased lines, so Hello matches hello. In both modes the result shows your original lines, not the normalized ones.
Common use cases
- Two API responses that should be identical: paste both and see the one field that changed. (For JSON where key order may differ, a structural JSON diff is a better fit.)
- Two LLM answers to the same prompt, to see what a prompt change actually changed.
- Config drift between two servers or environments, with Ignore whitespace on so indentation noise disappears.
- Reviewing an edit to a paragraph or a contract clause when you only have the before and after text, not the file history.
Limits worth knowing
- Windows (CRLF), old Mac (CR) and Unix (LF) line endings are all treated as a line break, so a file that only changed its line
endings shows no differences. Use a hex viewer or
git diffif line endings are what you are looking for. - Moved blocks show as a removal in one place and an addition in another; there is no move detection.
- Word highlighting only pairs lines when a run of removals is followed by the same number of additions, and very long lines are shown whole.