Toolstia / Text diff checker

Compare two texts line by line

When two versions of a document look almost the same, reading both side by side is slow and easy to get wrong. This checker lines the two versions up, finds what they have in common, and marks every other line as added or removed, so a changed price, a missing clause or a deleted setting stands out at once.

It works on whole lines, which suits the things people usually compare: contract drafts, article revisions, exported lists, configuration files, CSV rows, translation files and code snippets. Two switches let you ignore differences in capital letters and in spacing when those are just noise from a copy and paste. The summary line counts how many lines were added and removed, and tells you plainly when the texts match.

The comparison is done by script running in the page, so your text is not sent to a server for processing. There is a size limit, covered below, and the tool does not highlight changes inside a line.

Compare options

How it works

  1. Paste the original text on the left and the changed text on the right.
  2. Choose whether to ignore case or extra spaces.
  3. Read the highlighted result: green lines were added, red lines were removed.

How the comparison works

The tool finds the longest run of lines the two texts share, then marks everything else as added or removed. A line that was edited shows as one removed line and one added line.

Ignore options

Ignore case treats "Hello" and "hello" as the same. Ignore extra spaces treats runs of spaces and tabs as one space and ignores spaces at the ends of lines.

Size limit

Very long texts need a lot of memory to compare in the browser. If the text is too large you will see a message, and you can compare it in smaller parts.

Privacy

Both texts are compared on your device and are never uploaded.

A worked example you can try

Paste these three lines on the left: apple, banana, cherry. Paste these four lines on the right: apple, blueberry, cherry, date. The result reads: apple unchanged, banana removed, blueberry added, cherry unchanged, date added. The summary says 2 lines added and 1 line removed.

Notice that banana became blueberry, but the tool shows this as one removal and one addition, not as an edit. That is how every line-based comparison works, and it is why a long line with a single changed word still shows up as a complete red line followed by a complete green line. Read the pair together to spot the exact word that moved.

How the match between the texts is found

Each text is split into lines, and Windows, old Mac and Unix line endings are treated alike, so a file saved on one system compares cleanly with a copy saved on another. The tool then builds a table of the longest common subsequence of lines, which means the largest set of lines that appear in both texts in the same order. Lines in that set are shown as unchanged. Lines only in the original are removed, and lines only in the changed text are added.

When a block was both deleted and replaced, the removed lines are listed before the added lines. For unchanged lines the tool shows the version from the right-hand text, which matters only when you have turned on one of the ignore options.

Whitespace and capitals: when to ignore them and when not to

Ignore upper and lower case is useful when comparing lists of names or keywords that were retyped. Ignore extra spaces turns every run of spaces, tabs and other white space into a single space and trims the ends of each line, so a line indented with a tab matches the same line indented with four spaces.

Be careful with that second option for anything where indentation carries meaning, such as Python, YAML or Markdown lists. In those files an indentation change is a real change, and switching the option on will hide it. For prose, addresses and exported lists it is usually the right choice.

Reading a diff: moved lines, blank lines and trailing newlines

A paragraph that was moved from the top of a document to the bottom appears twice: once as removed where it used to be, and once as added where it is now. The tool does not detect moves, so a long list of red and green lines does not always mean much text changed.

Blank lines are lines too. If one text ends with a final line break and the other does not, the result shows a removed or added empty line at the very end. If a comparison reports differences that you cannot see, look for blank lines, or try the ignore spaces option, which makes a line containing only spaces equal to an empty line.

How large a comparison can be

The comparison table has one cell for every pair of lines, so its size is the number of lines in the first text multiplied by the number of lines in the second. The tool stops when that product passes four million, which is roughly two thousand lines against two thousand lines, and the table at that size takes about 16 megabytes of memory. Past the limit you see a message instead of a result.

If you hit it, compare the documents in sections, or remove the parts you already know are identical. Very long single lines, such as minified code, are fine for size but not useful for reading, because one changed character turns the whole line red.

Questions

Is my text uploaded?

No. The comparison runs in your browser.

Does it show changes inside a line?

No. It compares whole lines, so an edited line appears as removed and added.

Can I compare files?

Paste the contents of the files. Opening files directly is not supported yet.

Why does one changed word show the whole line as removed and added?

The tool compares lines, not words. A line is either identical in both texts or it is not. When a line differs, the old version appears as removed and the new version as added, and you compare the pair by eye.

Can it show which lines moved?

No. A moved block shows up as a removal at its old position and an addition at its new one. Move detection is not part of this tool.

What does Ignore extra spaces actually change?

Every run of white space inside a line becomes one space, and spaces at the start and end of each line are dropped before the lines are compared. Lines that differ only in spacing then count as equal.

How can I compare two long articles that exceed the size limit?

Split each into matching sections, for example a few hundred lines at a time, and compare section against section. Paragraphs that are one long line each also keep the line count low.

Why are two identical-looking texts reported as different?

Usually a hidden difference: a trailing space, a tab instead of spaces, different capitalization, or an extra blank line at the end. Turn on both ignore options and check whether the difference disappears.