Text Diff Checker

Compare two texts line by line. The longest common subsequence is found first, and whatever falls outside it is marked as added or removed. Useful for working out when and how a config file changed.

+2 −1 Unchanged 2

11name: Ada Lovelace
2−age: 30
2+age: 31
33city: London
4+phone: 020-0000-0000

Compared line by line.

How the comparison works

Both texts are split into lines, then the lines that match from the top and from the bottom are set aside first. The longest common subsequence is computed only for the middle that remains, so a long file with one change in it comes back almost instantly. Two texts that differ from start to finish need a table the size of the two line counts multiplied, and that gets slow in the thousands of lines. A line that appears in a different position on each side is not recognized as moved; it shows up twice, removed on one side and added on the other.

What ignoring whitespace actually does

When it is on, leading and trailing whitespace is stripped and runs of spaces and tabs inside a line collapse to one before comparing. This affects only the comparison — the table still shows the original text. Lines that only changed indentation, or went from tabs to spaces, become equal. A trailing CR counts as whitespace too, so a file from Windows and one from a Mac line up under this setting. Whitespace is not removed outright, though: a b and ab are still different.

Reading the table

The two left columns are line numbers in the original and the changed text. A removed line carries only the original number, an added line only the changed one. The counts above are added, removed and unchanged lines. An edited line counts as one removal plus one addition, so the figure is twice the number of lines you touched. The comparison reruns as you type.

Frequently asked questions

Can it compare character by character?

This works by line. Changing a few characters within a line marks the whole line as changed. If differences that are only indentation or spacing get in the way, turn on the option to ignore whitespace.

I changed one character and the whole line is marked.

Comparison is line by line. It reports that a line differs, not what within it changed. A file that is one long line — minified JSON, say — therefore looks entirely different; format it first and the change becomes visible.

They look identical but everything is marked as changed.

Usually the line endings. Files written on Windows end lines with CRLF, macOS and Linux with LF, which look the same and are not. Tabs versus spaces in indentation cause the same thing.

Can it ignore case or whitespace?

Whitespace, yes — turn on "ignore whitespace" and each line is trimmed and runs of spaces are collapsed before comparing. Case, no. The default is literal because in config files and code a single space can change the meaning, and a tool that quietly looks past it hides the difference you needed to see.

Can I upload two files to compare?

There is no file picker. Open them in an editor and paste. For a large file, pasting only the region that changed is faster than the whole thing — the more the two sides differ, the more the work grows with the product of their line counts.

How do I compare two JSON documents?

Format both the same way first. Minified JSON is one line, so the whole line reads as changed, and if the key order differs the same content looks different. This tool compares characters; it does not understand the meaning.

Does anything I paste get sent to a server?

No. Everything runs inside your browser and nothing is uploaded or stored. That is why you can use it on things you would not normally paste into a web page, like an internal config file or a production query. It also works with your network disconnected.