文本差异对比工具

对比两段文本,精确标出新增和删除的行。左右对照、颜色区分、清晰易读。

How diff works

A diff algorithm finds the longest common subsequence between two texts — the largest set of lines that appear in both, in the same order. Everything left over is either an addition or a deletion.

This matters because a naive line-by-line comparison produces noisy output. Change one line in the middle of a paragraph and a naive diff flags every subsequent line as changed. The LCS approach correctly identifies that only one line actually differs.

Reading the output

  • Red lines (-) were removed from the original
  • Green lines (+) were added in the new version
  • Unmarked lines are identical and shown for context

Common uses

  • Reviewing a revision before sending it
  • Checking whether a config file changed
  • Comparing a generated output against a template
  • Spotting a subtle edit in a contract or changelog

Tip

For large files, diff on the command line gives you more control:

diff -u original.txt modified.txt

Add --color=always for readable output and -w to ignore whitespace-only changes.

常见问题

Is my text uploaded anywhere?

No. The comparison runs entirely in your browser.

How does it decide which lines changed?

It finds the longest common subsequence between the two texts, then reports everything left over as added or removed. This avoids flagging every line after a small edit.

Can it compare files?

Paste the contents of both files into the two fields. For very large files, the diff -u command is considerably faster.

Does it ignore whitespace?

No, whitespace differences are reported. Run diff -w on the command line if you want to ignore them.

Is it case-sensitive?

Yes. Hello and hello are treated as different lines.