Text compare β what changed, and why unchanged text sometimes looks changed
Put two versions side by side and see only what differs. Two drafts, code before and after, a translation against its source, two lists of names. The job is finding the one character your eye skips over, so counting accurately is the whole thing.
Comparing means finding the longest run the two texts share and calling everything left over an insertion or a deletion. It is called the longest common subsequence, and it is the same calculation behind βtrack changesβ in a word processor.
This tool offers both line and character comparison. Lines suit text where a line is the unit of meaning β code, lists, tables. Characters suit prose, where you want to see that a single word inside a sentence moved.
The same text can be stored two different ways
Text typed on a Mac often arrives decomposed: an accented letter, or a Korean syllable, is several code points rather than one. It looks identical on screen and compares as different β μλ νμΈμ is twelve pieces from one machine and five from the other.
Compare that directly and every line containing such text shows as changed, even when not one character was edited. The whole document lights up red and green for nothing. This tool normalizes both sides first, so a file from either machine reads as the same text.
If you are ever comparing a file received from a colleague against one you made yourself, this is the first thing that goes wrong.
Why the browser does not freeze on a long document
The textbook method builds a table the size of one text multiplied by the other. Ten thousand lines against ten thousand is a hundred million cells β 382MB at four bytes each. That does not run slowly; it stops the tab. A single long paragraph pasted out of a PDF, with no line breaks, does the same thing.
This tool uses Hirschberg's algorithm, which keeps one row at a time and splits the problem in half instead of holding the whole table. It finds the same longest common subsequence β the answer is not approximated to save memory, only the bookkeeping is.
Measured
The middle column is the memory the table method would have needed.
| Lines | Table method | Time taken |
|---|---|---|
| 1,000 | 4MB | 13ms |
| 5,000 | 95MB | 182ms |
| 10,000 | 382MB | 755ms |
When this is the right tool
- β’An edited draft came back without a note saying what was edited.
- β’Checking that a translation has the same number of paragraphs as its source.
- β’Reconciling two lists of names to find who is missing.
- β’Remembering what you changed in a config file.
- β’Finding the typo that crept in during a copy and paste.
Frequently asked questions
Line or character comparison?
If a line is the unit of meaning β code, lists, tables β use lines. For prose where line breaks are just paragraph ends, characters read better. On a heavily rewritten text, character mode turns into noise.
I changed one line and several are marked.
Splitting or joining a line makes everything around it look different. The calculation is not wrong; in line terms that much genuinely did change. Switch to character mode to see what moved.
Are whitespace differences counted?
Yes. An invisible difference is still a difference β tabs against spaces, trailing spaces, Windows line endings. If whitespace is all you want to fix, a whitespace cleaner is the better tool.
Is the text stored anywhere?
No. The comparison happens entirely in your browser.
