Text Diff Tool
Paste two pieces of text and see exactly what changed. Additions are highlighted in green, deletions in red, and unchanged lines fade into the background. Works on prose, code, JSON, YAML, log output, or any text where you need to track what moved between two versions.
Why Diffing Matters
Most editorial and engineering work is iterative: a draft, then a revision, then another. When the changes get past a sentence or two, eyeballing them stops working. A diff turns what changed? into a visual answer in under a second. The same principle drives version control systems like Git, but you don't need a repo or a commit history to compare two snippets — just paste and look.
This tool runs the diff entirely in your browser using a longest-common-subsequence algorithm. Nothing uploads, which matters if you're comparing draft contracts, internal documents, or anything covered by an NDA. For structural comparisons of formatted code, pair this with a JSON formatter or code beautifier first so whitespace doesn't dominate the diff.
How It Works
The diff operates line by line. Each line in the original is matched against the modified version using a longest-common-subsequence comparison, which finds the fewest added and removed lines. Lines present in both versions stay neutral; lines only in the original render as deletions; lines only in the modified version render as additions. The ignore whitespace toggle collapses leading/trailing space differences before comparison, useful when the only change is indentation. Ignore case treats Hello and hello as the same line.
Word-level highlighting inside changed lines is a stretch goal for a future revision. For now, line granularity catches the overwhelming majority of real review cases, and it scales to thousands of lines without slowing the browser.
Common Use Cases
Writers comparing draft and revised sections of a piece. Developers reviewing what a teammate changed before pulling it down. Lawyers running redlines on contract clauses (use the HTML entity encoder first if your clauses contain quotes that get mangled in transit). Sysadmins comparing config files between staging and production. Anyone reconciling two slightly-different exports from the same source system to find the field that drifted.
Worked example: the same edits through this tool and git
We generated a 2,000-line file and three edited versions on October 12, 2026. Each pair went through the tool's own diff function (Node 22) and through git diff --no-index with git's default Myers algorithm and with --diff-algorithm=histogram.
| Edit | This tool (added / removed lines) | git, Myers | git, histogram |
|---|---|---|---|
| 40 lines changed at random places | 40 / 40 | 40 / 40 | 40 / 40 |
| A 50-line block moved from line 100 to line 1500 | 50 / 50 | 50 / 50 | 50 / 50 |
| Every 10th line indented by 4 spaces | 200 / 200 | 200 / 200 | 200 / 200 |
The counts match git in all three cases. Two of them are worth reading closely:
- A moved block shows as a deletion plus an addition. Line-based diffs, git's included, have no concept of "moved". The 50 lines appear in red where they were and in green where they landed. To confirm nothing changed inside a moved block, diff the block on its own.
- Re-indenting floods the diff. Indenting 200 lines makes all 200 count as changed. Turn on Ignore whitespace, which trims each line and collapses runs of spaces and tabs before comparing, so the real changes stand out. git's
-woption, which ignores all whitespace, is the closest equivalent.
How big can the texts be?
The comparison builds a full longest-common-subsequence table: one cell for every pair of lines, so its memory grows with lines × lines. In Node 22 the diff alone took about 0.05 s and 11 MB of heap for two 1,000-line texts, 0.7 s and 155 MB for 5,000 lines, and 2.3 s and roughly 850 MB of memory for 10,000. Up to a few thousand lines it is effectively instant. Near 10,000 lines on a phone or a low-memory laptop the tab may run out of memory. For very long files, compare sections, or use git diff --no-index file1 file2, whose Myers algorithm needs far less memory.
Sources
Checked on .
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools