Text diff checker

Paste one text in each field and the tool compares them line by line: it shows what is identical, what was added and what was removed, with the line number in each text. Everything happens in your browser — not one character you type is sent to a server.

A detail that catches people: a trailing space is a difference. “word ” is not the same as “word”. It sounds trivial until you need it — this is exactly what hunts the phantom diff in your editor, the file that shows as modified after you merely opened it, because saving added or removed a space at the end of a line.

The comparison has a declared limit: the matrix that solves the problem fits in at most 2 million cells, which in practice means texts that share very little, roughly 1,400 fully different lines on each side. Before the matrix runs, identical leading and trailing sections are cut for free, so two similar files with one change in the middle fit comfortably even with thousands of lines. Past the limit the page tells you, instead of freezing the tab.

How to use

  1. Paste the original text in the left field — the older version, the one in the repository, the reference you want to compare against.
  2. Paste the compared text in the right field — the newer version, the result you want to check.
  3. Read the three counters at the top: lines added, lines removed, lines unchanged. Lines marked in red were dropped from the original; green ones were introduced by the compared text.
  4. If you need the result somewhere else, press copy: it leaves line by line, with each side’s number and the addition or removal sign, ready to paste into a terminal or an editor.

What the comparator counts as a line

Normalization comes first: CRLF (the Windows end-of-line) and a bare CR become LF before any counting. A file saved on Windows and opened on Linux shows no difference at all if the content matches.

Then both ends are trimmed: the identical prefix and suffix of the two texts are cut out without entering the matrix — they are equal by construction. Only the differing middle goes through the computation, which is what makes long files with one isolated change cheap to compare.

In that middle section the tool finds the longest common subsequence of lines: the largest set of lines appearing in the same order on both sides. Those come out as unchanged; the rest becomes removal or addition. Inside an altered block, removed lines are listed before added ones.

A blank line is a counted line: between two consecutive line breaks there is an empty line, and it shows up in the result with its number like any other. The file’s final newline counts too — text ending with a line break has one empty line more than the same text without it.

CaseWhat the tool doesWhy
“a ” against “a”1 removed and 1 addedA trailing space changes the line’s text; comparison is exact.
“a\r\n” against “a\n”No differenceCRLF is normalized to LF before comparing.
Empty field against a textEverything on one side onlyAdding a whole text to an empty field is pure addition, not an error.
3,000 lines swapped for other 3,000Refused with a named warningThe comparison matrix would exceed 2 million cells; a warning beats a frozen tab.

Frequently asked

I changed a single word and the diff removes and re-adds the whole line. Why?
Because the unit of comparison is the whole line, not the word or the character. A changed line appears as one removal followed by one addition, even if the difference inside it is a single letter. That is the same convention as the default git diff, and it exists so you reread the new line as a sentence instead of hunting for a hidden character.
How do I compare very large or very different files?
Split them into smaller parts: compare section by section, or keep only the stretch of each file that matters. The tool refuses when the matrix would go past 2 million cells — an honest warning instead of a frozen tab. If the files share a long beginning or ending, you never get close to the limit, because that part is removed for free before the computation.
Does my text leave the browser?
No. The whole comparison runs in the page’s JavaScript: nothing is sent to any server, nothing is written to disk, and closing the page takes the result with it. You can compare with the network unplugged once the page has loaded.
Why does removal come before addition inside a changed block?
To keep the block readable: first everything dropped from the original, then everything introduced by the compared text, with each side’s line numbers advancing without interleaving. Had the two lists come out mixed, following which line corresponds to which would become manual work.
Do repeated lines mess up the result?
They don’t. The common subsequence aligns each occurrence where it belongs: against “a, a” the tool removes the middle “b” from “a, b, a” and counts both “a” lines as unchanged, instead of flagging the last one as different. Order of appearance is what rules, not the first match.

Related tools