gratislab100% FREE

Compare Two Texts, Line by Line

Put the version you started with in one box and the version you want to check in the other. The page lines them up and marks every row that differs — added, removed or replaced — and writes the result out as a patch file, which is the format anybody who works with code will already recognise.

Two versions, one in each box · a document, a list, a config file, code0 words · 0 characters

The version to check against the first · compared line by line0 words · 0 characters

Line endings and carriage returns
Nothing uploadedNo sign-upNo watermarkHow that works

How to compare two texts, line by line

  1. Paste the version you started with into the first box.
  2. Paste the version you want to check against it into the second.
  3. Press Compare the two. Rows that differ are marked; rows that match are left plain.
  4. Save the file if you want the differences as a patch to send on.

Why two texts that look identical still differ

Most of the time the difference has no shape on screen. A trailing space at the end of a line, a tab where the other copy has four spaces, one file saved with Windows line endings and the other with Unix ones. All invisible, and any of them enough to make a comparison call every single line changed.

Line endings are ignored here to start with, so a Windows copy and a Unix copy of the same words come back identical rather than entirely different. Ignoring case and collapsing runs of whitespace are two more switches, and both begin off, because the first thing you usually want to know is whether the two are literally the same.

What a marked row is telling you

Every row is a whole line. When a line has been edited you see the old one and the new one beside each other, but the changed word inside it is not highlighted — that refinement is not built yet, and saying so beats letting you assume a one-character edit will be pointed out for you.

The counts above the table are lines added, lines removed and lines changed. A pair of rows counted as changed is one line replaced by another; a row with nothing opposite it is a line that exists on only one side.

Comparing two texts that share almost nothing is the expensive case, and done naively it can lock a mid-range phone up for ten or fifteen seconds. This page stops instead. If the work runs past its budget the changed region comes back as one block replacement with a note saying that is what happened — a rough answer quickly, rather than a page that appears to have died.

The other case worth knowing is a paste with no line breaks in it at all. A comparison of lines has nothing to grip, so the whole paragraph is treated as one very long line and marked as changed. Break it at the full stops first and the comparison becomes useful again; the page says so when it notices.

Questions

Can I drop two files in instead of pasting?
Not on this page. It takes typed or pasted text in two boxes, so open each file in whatever made it, select everything, and paste each one into its own side. On a phone that is usually the quicker route anyway.
Is this the same thing as a git diff?
The output has the same shape — a unified patch with three lines of context around each change — and the comparison uses the same family of algorithm. It knows nothing about commits, branches or repositories. It compares two pieces of text you paste, and that is all.
It says they are identical, but the two files are different sizes.
Then the difference is in the line endings or a stray carriage return, both of which are ignored by default so that a Windows copy and a Unix copy match. Turn that off to compare them exactly and the two will separate.
Do either of the texts leave my device?
No, both stay in the page. That is the reason to use this instead of a site that asks you to upload two documents — the pairs people most often compare are two drafts of an agreement and two versions of a settings file, and neither belongs on somebody else's server.

Text & utilities