文本比较工具

最后更新:

关于此工具

文本差异工具按行比较两段文本,以颜色标注新增、删除和未变化部分。可在尚未纳入版本控制的配置片段、API 响应、翻译稿等任意文本上使用,提供与 git diff 一致的视图。

使用方法

  1. Paste the original text into the left input.
  2. Paste the new or modified text into the right input.
  3. Click Compare to render the unified diff below.
  4. Read green lines as additions and red lines as deletions; identical lines are dimmed.
  5. Use the result to spot regressions, validate translations, or document a change.

常见用例

  • Comparing the response of an API before and after a backend deployment.
  • Reviewing two versions of a contract or copy block side by side.
  • Checking what changed in a YAML / JSON configuration file.
  • Verifying that a refactored function produces identical log output.
  • Spotting subtle differences between two SQL query plans.
  • Catching whitespace or line-ending changes that hide in normal editors.

常见问题

Q. Is the diff line-based or character-based?

A. Line-based, like git diff. Two lines that differ by one character render as one removal and one addition rather than an inline highlight.

Q. How is whitespace handled?

A. Whitespace differences cause line mismatches. To ignore them, normalise both inputs (trim trailing spaces, convert tabs to spaces) before pasting.

Q. Will it work for very large files?

A. It runs in your browser, so performance depends on your machine. Tens of thousands of lines are usually fine; for huge files prefer git diff or diff -u from the command line.

Q. Does the comparison get sent to a server?

A. No. The diff runs locally in JavaScript, so confidential text never leaves the browser tab.