Diff比较

比较两个文本文件并高亮显示差异。

原始文本
修改后文本
What is Diff?

Diff is the process of comparing two pieces of text to find and display their differences. Originally a Unix utility, diff algorithms are now fundamental to version control systems, code review tools, and document comparison software. Different diff algorithms optimize for various use cases like minimal changes or semantic understanding.

How Diff Works

Diff algorithms typically use techniques like Longest Common Subsequence (LCS) to find the minimal set of changes between two texts. Results show additions (new lines), deletions (removed lines), and modifications (changed lines). Advanced diffs can show character-level changes within modified lines.

Cron 解析器
  • Comparing code versions before merging
  • Reviewing configuration file changes
  • Validating document revisions
  • Debugging by comparing expected vs actual output
  • Tracking changes in data exports
Features
  • Side-by-side comparison view
  • Line-by-line difference highlighting
  • Added and removed line indicators
  • Character-level change detection
Frequently Asked Questions

What's the difference between unified and side-by-side diff?

Unified diff shows changes in a single column with +/- markers, more compact for patches. Side-by-side diff shows both versions in parallel columns, easier for visual comparison.

How can I ignore whitespace differences?

Most diff tools offer options to ignore whitespace changes. This is useful when comparing code with different formatting but identical logic.