What a Diff Tool Does
A diff tool compares two versions of text — file A and file B — and outputs a list of differences between them. Which lines were added (in B but not A), which were removed (in A but not B), and which are the same in both.
The name comes from the Unix diff command, which has been a standard part of Unix systems since 1974. Every modern development workflow relies on diff in some form — Git's git diff command, code review tools on GitHub and GitLab, merge conflict resolution in every IDE, and online tools for quick comparisons.
Understanding Diff Output
The two main display formats are unified diff and split diff.
Unified diff shows both versions in a single column, with removed lines marked with a minus sign and a red background, and added lines with a plus sign and a green background. This is the format Git uses in the terminal. It is compact and good for following the flow of changes.
Split diff shows the two versions side by side — the original on the left, the modified on the right. Changed sections are aligned with each other. This format makes it easier to see exactly what was before and what replaced it, especially for complex changes.
Beyond line-level diff, modern diff tools also do word-level (or character-level) inline diff. When a line is modified rather than entirely replaced, the specific words that changed are highlighted within the line. So instead of just seeing the whole old line and whole new line, you see exactly which words were added or removed.
The Algorithm Behind It
Most diff tools use the Myers diff algorithm (published by Eugene Myers in 1986), which finds the minimum number of insert and delete operations needed to transform one sequence into another. This is called the shortest edit script or the longest common subsequence (LCS) problem.
The algorithm works on sequences of lines. It finds the longest sequence of lines that appear in both files (in the same order) — those are the unchanged lines. Everything else is either an insertion or a deletion.
This is why diff output sometimes looks surprising. The algorithm optimizes for fewest total changes, which occasionally groups them differently than a human would. Large refactors where lines move around rather than change in place can look messier than they are.
Practical Uses for Diff Checking
Code review — Comparing a feature branch to the main branch to understand what changed before merging.
Document revision — Comparing two versions of a contract, report, or legal document to see exactly what was modified between drafts.
Configuration auditing — Comparing server configuration files to spot unauthorized changes or drift from the expected baseline.
Debugging regressions — Finding what changed between a working version and a broken version of code when a bug was introduced.
Content changes — Comparing two versions of a webpage, article, or API response to see what changed over time.
Using the Diff Checker Tool
Paste your original text in the left panel and your modified text in the right. Click Compare. The tool uses the LCS algorithm to produce a line-level diff with inline word-level highlighting for changed lines.
Switch between Split view, Unified view, and Summary view. Toggle Ignore Whitespace to skip formatting-only differences. Toggle Ignore Case for case-insensitive comparison. Adjust context lines to show more or fewer unchanged lines around changes. Export the full diff as a standard .txt file.
Related Topics
Try it yourself
Diff Checker
Everything in this article is available in the free tool. No account, no subscription, no install.
Open Diff Checker →