Sometimes you need to know exactly which lines changed after editing a config file, or you're staring at two versions of a document and can't tell what's different just by eye. This article covers what a diff (comparison) tool actually does, the situations where it's useful, and how to read its output.
What a Diff Tool Does
A diff tool compares two pieces of text line by line and figures out which lines stayed the same and which were added or removed. Internally, it typically uses an algorithm like LCS (Longest Common Subsequence) to find the longest run of lines common to both texts, then labels everything outside that common run as "added" or "removed." If even a single word changes within a line, the entire line is treated as changed, because the unit of comparison is the line, not the word (spotting exactly which word changed would require a separate word-level diff). The end result is that you can pinpoint the actual points of change far faster than by placing the original (A) and the comparison text (B) side by side and reading through both manually.
Common Use Cases
Diff works for version comparison on almost anything expressed as text. The most common case is configuration files: after editing an nginx config or an .env file, comparing it against the original before deploying immediately confirms that only the intended lines changed and no other option was accidentally touched. It's just as useful for documents — comparing two revisions of a contract or a project spec lets you see which clauses or paragraphs were added or removed without reading the whole thing start to finish. For code, it's also useful as a quick pass before committing, to preview what actually changed. Version control systems like Git already show you diffs, but for text that isn't tracked in a repository — notes, throwaway scripts, files someone sent you — you need a standalone diff tool.
How to Read the Output
Diff output typically marks the type of change with a symbol or color in front of each line. A common convention is to mark "removed" lines — present in the original but missing from the comparison text — with a minus (-) sign in red, and "added" lines — new in the comparison text — with a plus (+) sign in green. Lines with no marker exist identically in both texts and are unchanged. When only part of a line's content changes, it's usually shown as a "removed" line (the old content) immediately followed by an "added" line (the new content), letting you compare the old and new values at a glance. Once you know these conventions, you can quickly pick out exactly what changed even in a file that runs to hundreds of lines. Instead of comparing line by line yourself, pasting your text into two boxes and letting a tool highlight the added and removed lines in color saves the manual work entirely.
🆚 Try it yourself with the tool
How to Compare Two Text Files (Diff Checker) — Quickly spot differences between two versions