工具 指南
text 免费 无需注册

文本差异高亮工具

以词级、字符级或行级差异高亮比较两段文本。

正在加载工具…

关于此工具

粘贴两段文本,立即查看变化之处。在词级、字符级和行级差异模式之间切换。新增内容以绿色高亮显示,删除内容以红色加删除线标注,并显示相似度得分。

使用方法

  1. 1 第一步:在左侧面板中粘贴或输入原始文本。
  2. 2 第二步:在右侧面板中粘贴或输入新/修改后的文本。
  3. 3 第三步:选择差异模式:词级、字符级或行级。
  4. 4 第四步:以内联方式查看高亮差异或切换到并排视图,并检查统计摘要。

What a text diff actually computes

Comparing two pieces of text is not as simple as walking them side by side and flagging the first character that differs — that would mark everything after a single inserted word as "changed." A proper diff finds the longest common subsequence (LCS): the largest set of pieces that appear, in the same order, in both versions. Whatever is left over on the original side was deleted, and whatever is left over on the new side was added. This tool implements that LCS algorithm directly, so it identifies the smallest real set of insertions and deletions rather than a naive position-by-position mismatch.

Three granularities: line, word, and character

The same text can be compared at three levels, and choosing the right one is the difference between a useful diff and a noisy one:

ModeComparesBest for
Linewhole lines split on newlinesCode, config files, logs — anything line-structured
Wordwords and the whitespace between themProse, edited paragraphs, copy revisions
Characterevery single characterSpotting a one-letter typo or a changed digit

Word mode is the most common choice for everyday text because it keeps unchanged words intact and highlights only the words that moved, while line mode mirrors what developers see in version control. Character mode is the most precise but also the busiest — use it when you suspect a tiny change you cannot find by eye.

A worked example

Put The quick brown fox on the left and The slow brown fox jumps on the right, in word mode. The LCS is "The brown fox" — those words survive in order. The tool marks quick as removed (struck through, red), slow as added (green), and jumps as added at the end. It then reports the statistics: +2 words added, −1 word removed, and a similarity score. Similarity is computed as twice the number of matching tokens divided by the total tokens in both texts, expressed as a percentage — so two identical texts read 100%, and texts with nothing in common approach 0%.

Inline versus side-by-side views

The inline view weaves both versions into one stream: deletions struck through in red, insertions highlighted in green, sitting next to the unchanged text. It is compact and good for short edits. The side-by-side view puts the original on the left with only its deletions marked and the new version on the right with only its additions marked, which makes it far easier to read a heavily rewritten passage. You can switch views freely; the underlying diff is the same, only the presentation changes.

Practical use cases

  • Reviewing edits. Paste a draft and its revision to see exactly what an editor or collaborator changed, word for word.
  • Catching silent config changes. Diff two versions of a settings file in line mode to find the one value that was altered.
  • Comparing terms or contracts. Word mode surfaces every clause that was added, removed, or reworded.
  • Verifying a copy-paste. Character mode confirms whether two strings that look identical truly are, down to a trailing space.

Common mistakes and limits

  • Using character mode on long text. It produces an overwhelming amount of highlighting and is slow; reach for word or line mode unless you are hunting a single character.
  • Forgetting whitespace counts. In word mode the spaces between words are tokens too, so a change in spacing can show up as a difference — usually what you want, occasionally surprising.
  • Pasting huge inputs. The LCS algorithm builds a comparison grid, so cost grows with the product of the two token counts. This tool caps the combined size (around 20,000 tokens total) and warns you to trim the input rather than freezing the page.
  • Expecting it to detect moved blocks. A paragraph relocated from top to bottom reads as one deletion plus one insertion, not a "move" — that is inherent to how diffs work.

Privacy

Both texts are compared entirely in your browser using the built-in algorithm — nothing is uploaded or stored on a server. That makes it safe to diff confidential drafts, internal config, or unreleased copy, and it works even with your network disconnected.

常见问题

{# Alpine.js — self-hosted. (The previous jsdelivr CDN tag had a stale SRI integrity hash, so the browser refused to run it and window.Alpine was never defined — silently breaking every FAQ accordion and Alpine tool.) #}