Skip to contentSkip to the inputSkip to the result

Compare two texts

See added and removed lines between versions.

Loading tool

Instructions

Compare two texts

How to use

  1. Enter the old and new text, then compare.
  2. Read the addition and deletion markers.

Supported input

  • Uses a real line diff algorithm and marks the changed words.
  • Spaces or case can be ignored.
  • Saves a unified diff (.diff) too.
  • Maximum 200,000 input units per text.

Input example

Old: apple; New: pear

Result example

 Removed apple; added pear

Troubleshooting

  • Check required inputs, numeric ranges and the selected conversion direction.

How it works

  • See added and removed lines between versions.

Comparing two versions line by line, and reading the result

What it is good for

  • Checking a contract the other side sent back for clauses that changed without being mentioned.
  • Listing exactly what changed between two editions of a policy, report or notice before you publish.
  • Recording which settings changed in a configuration file before and after an edit.
  • Sending only the changes, as a .diff file, to someone who should not receive the whole document.

How the changed lines are found

The comparison uses the line diff of jsdiff, a library built on Eugene Myers’ O(ND) difference algorithm. It looks for the smallest set of line deletions and insertions that turns the old text into the new one, keeps every line the two share in place, and marks the rest with − (only in the old text) or + (only in the new one).

There is no notion of a moved line. Move A below B in A, B, C, D and the result is −A, B, +A, C, D: one copy removed here, another added there.

Ignoring spaces trims each line and treats any run of spaces inside it as one before comparing; ignoring case treats capital and small letters as the same.

Worked example: a contract with two edits

  1. 1The old text has eight lines, Clause 1 to Clause 4 each followed by a sentence. The new text changes “The term is one year.” to “two years.” and “Notice is 30 days.” to “60 days.”
  2. 2The line view shows six unchanged lines without a mark, and each edited sentence as a − line followed by a + line.
  3. 3Saved as .diff, the result is two header lines (--- before.txt and +++ after.txt) and one hunk, @@ -1,8 +1,8 @@: eight lines starting at line 1 of the old text become eight lines starting at line 1 of the new one, because the two edits are close enough to share their three lines of context.
  4. 4Edits far apart get hunks of their own. In a 20-line text with lines 3 and 18 changed, the file holds @@ -1,6 +1,6 @@ and @@ -15,6 +15,6 @@.

Using the .diff file elsewhere

  • It is the unified format of GNU diff, so patch or git apply can apply it to the original. The headers name before.txt and after.txt; rename them, or point the command at the right file.
  • A text whose last line has no line break gets the marker line “\ No newline at end of file”. That is part of the format, not an error.
  • A diff saved with spaces or case ignored leaves those differences out, so turn the options off before saving a patch you intend to apply.

When a line diff looks wrong

  • A paragraph written as one long line shows as entirely changed after a single comma is edited. Put one sentence per line in both texts with the line-break tool, then compare, and only the edited sentence shows.
  • Text copied from a PDF and from a word processor breaks lines in different places, so nearly every line differs even when the words are the same. Normalise the line breaks in both first.
  • Different line endings, Windows CR LF against LF, can make identical lines show as changed.
  • One final line break present in one text and missing from the other is ignored in the line view, so the two do not differ on that alone. The same holds when a last line without a line break, D, moves to the middle of the new text with more lines after it (A, B, C, D against B, C, D, A): D shows as kept, not as removed and added, and only A moves. The .diff file, following its format, still writes that line as changed with “\ No newline at end of file”.

Checked

Frequently asked questions

How are changes shown?

Lines only in the old text are marked −, lines only in the new text +. When part of a line changes, the changed words are highlighted, and a side-by-side view is available. Runs of 8 or more unchanged lines are folded.

How long can each text be?

Up to 200,000 characters each. The comparison runs in a browser worker apart from the page, so the page stays responsive while it works; it stops after 8 seconds, so split very different long documents. The result can also be saved as a unified diff (.diff) file that patch and git read.

Why does a spacing change show as a difference?

By default lines are compared character for character, so one extra space, a trailing space or a case change counts. Set Ignore differences in to Spaces and each line is trimmed and any run of spaces inside it read as one before comparing, so 'a b' and 'a b' match; choose Letter case to ignore capital and small letters.