Text Diff Tool

Paste two versions of a text to see the line and character differences.

Result

2 lines
1 line
2 lines
7 chars

How it is calculated

Both texts are split into lines. The tool finds the longest set of identical lines that appear in the same order in both (a longest common subsequence). Those are the unchanged lines; added = lines in B − common and removed = lines in A − common. A line that was edited therefore counts as one removed plus one added. Lines must match exactly, including case and spaces. The character figure is the Levenshtein distance: the fewest single-character insertions, deletions and substitutions that turn A into B. It is computed on bytes, so an accented letter such as é counts as 2, and when either text is longer than 4,000 characters the character figure shows “—” (the line counts are still given). At least one box must contain text.

Worked example

Text A has 3 lines: "The cat sat", "on the mat", "The end". Text B has 4 lines: "The cat sat", "on the rug", "The end", "Bye". Two lines match in order, so common is 2 lines. B has 4 − 2 = 2 lines added (the rug line and Bye), and A has 3 − 2 = 1 lines removed (the mat line). Characters: mat becomes rug with 3 substitutions, and the line break plus Bye needs 4 insertions, so 7 chars in total.

Try this example →

Common mistakes

  • Expecting an edited line to be counted as one change. It appears as one line removed and one added.
  • Ignoring invisible differences. A trailing space, a tab or a different capital letter makes two lines unequal.
  • Comparing texts with different line endings or wrapping. A paragraph broken at different widths is seen as completely different lines.
  • Treating the character count as a count of words changed. It counts single characters, so one replaced word can be several changes.
  • Relying on the character distance for very long texts. Above 4,000 characters in either box it shows “—”; only the line counts are given.

About this calculator

This tool compares two blocks of text on two levels: a line-level diff, which reports how many lines were added, removed, or left unchanged between the two versions, and a character-level edit distance (Levenshtein distance), which counts the minimum number of single-character insertions, deletions, and substitutions needed to turn one text into the other.

Software developers use line diffs constantly when reviewing code changes in version control, while writers, editors and translators use the same comparison to spot exactly what changed between two drafts of a document — the character-level distance adds a finer-grained view for catching small wording or formatting edits that a line-by-line comparison alone would report as a single “changed line.”

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    For texts over 4,000 characters on either side, the character count is not calculated: the tool shows a dash there, while the line counts stay exact. For big documents, trust the lines and compare sections separately if you also want a character figure for each part. Remember that an edited line counts as one removed and one added. What kind of text do you compare most: code, contracts or drafts?

Popular calculators

All Calculators