Text tool

Text Diff Tool

Review line-level changes between two text versions with clear indicators for added, removed, and unchanged lines.

For responsiveness, each side is limited to its first 500 lines.

Line diff (+ added, − removed)

How the line-based diff comparison works

The tool compares two texts line by line using a longest-common-subsequence (LCS) algorithm, which identifies the longest sequence of lines that appear in both texts in the same order. After finding the LCS, any lines in the original text that are not part of the LCS are marked as removed, and any lines in the revised text that are not part of the LCS are marked as added. Unchanged lines (those in both texts) are prefixed with two spaces in the output.

Each input is capped at 500 lines for browser responsiveness. The two textareas accept the original text and the revised text, and the output shows the comparison result with prefixes: ' ' for unchanged lines, '+ ' for lines added in the revised text, and '- ' for lines removed from the original text. A line that changed (different in both texts) appears as both a removal and an addition, since a line-based diff cannot represent character-level changes within a line.

Comparing two email drafts

  • Original: "Hello Alice,", "How are you?", "I'm doing well.", "Best regards"
  • Revised: "Hello Alice,", "How are you doing?", "I'm doing well.", "Thanks"
  • Diff output: " Hello Alice," (unchanged), "- How are you?" (removed), "+ How are you doing?" (added), " I'm doing well." (unchanged), "- Best regards" (removed), "+ Thanks" (added)
  • The middle line 'I'm doing well.' is common to both versions and appears with two spaces
  • Line 2 changed from 'How are you?' to 'How are you doing?', so both the old and new versions appear in the diff

Reviewing document revisions and API responses

The diff tool is useful for code review when comparing two versions of a script or configuration file without using Git. Paste the old version in the original field and the new version in the revised field to see exactly which lines were added, removed, and preserved. This helps identify unintended changes or confirm that updates are minimal. For large files, the 500-line limit ensures the comparison completes quickly; if your file is larger, split it into sections and diff them separately.

A practical scenario is comparing API response outputs from different systems or time periods. If an API returns one line per record and you want to see which records are new, which are gone, and which are stable, paste the two response lists (one item per line) and run the diff. Similarly, reviewing changes to a configuration file, a build output log, or a database export becomes straightforward: each line is compared in sequence, and additions and removals are immediately visible.

Limitations and typical diff scenarios

  • Character-level changes are not shown: if a line changes from 'color' to 'colour', the diff reports a removal and an addition, not an internal character change, because the tool operates at the line level.
  • Whitespace matters: a line with leading spaces is different from the same line without leading spaces, so they appear as separate removal and addition lines.
  • 500-line cap: each side is limited to its first 500 lines, and a note under the inputs states this. Lines beyond 500 are not compared.
  • Order sensitivity: if the same lines appear in a different order between the two versions, they are treated as removals and additions, not rearrangements.
  • Word order changes: if a line has the same words but in a different order, it appears as a removal plus an addition.

Frequently asked questions

Why does a small change to a line show as both a removal and an addition?

The diff is line-based, not character-based. If 'hello world' changes to 'hello there', the entire line is considered changed, so the old line appears as a removal and the new line as an addition. Character-level diffing would highlight only the 'world' versus 'there' difference.

What is the longest-common-subsequence algorithm?

The LCS algorithm finds the longest sequence of lines that appear in both texts in the same order, without requiring them to be consecutive. This matching approach identifies truly unchanged lines and minimizes false removals and additions.

Are leading spaces or indentation changes shown as differences?

Yes. A line with different leading whitespace is considered a different line. If indentation changes, the tool reports the line as both removed and added.

What if the same line appears twice in the original text?

Duplicate lines are handled by the same matching rules as everything else: the algorithm keeps whichever occurrences contribute to the longest common subsequence overall. One copy may show as unchanged while another shows as removed, depending on what the revised text contains.

Can I compare more than 500 lines?

No. Each side is capped at 500 lines to keep the comparison fast in the browser. If you need to diff larger files, split them into chunks and diff each chunk separately, or use a command-line diff tool like 'diff' on Unix systems.

Is blank line movement detected as a change?

Yes. If blank lines shift position between versions, they are treated as removals and additions at their original and new positions. Use Whitespace Cleaner to normalize blank lines before diffing if spurious spacing changes are a problem.