H ToolHub / 所有工具 / 文本差异比较
↔️ 文本工具

文本差异比较

在线文本差异比较工具,对比两段文本的差异,支持行级和字符级差异高亮显示。

什么是文本差异比较?

文本差异比较(Text Diff)是找出两段文本之间不同之处的过程。这是版本控制系统(如 Git)的核心功能,也广泛用于代码审查、文档对比和配置变更检测。

本工具支持两种比较模式:

  • 行级差异:以行为单位比较文本,标记新增行(绿色)和删除行(红色),适合比较代码或文档的不同版本
  • 字符级差异:以词为单位比较文本,在行内高亮显示具体变化的词,适合精确查看修改内容

差异算法基于最长公共子序列(LCS),能够准确识别文本的增删改操作。所有比较在浏览器本地完成,数据不会上传。

What is Text Diff?

Text Diff is the process of finding differences between two texts. It's the core functionality of version control systems (like Git) and is widely used for code review, document comparison, and configuration change detection.

This tool supports two comparison modes:

  • Line Diff — Compares text line by line, marking added lines (green) and removed lines (red). Ideal for comparing different versions of code or documents
  • Character Diff — Compares text word by word, highlighting specific changes inline. Great for seeing exactly what was modified

The diff algorithm is based on Longest Common Subsequence (LCS), accurately identifying insertions, deletions, and modifications. All comparison is done locally in your browser — no data is uploaded.