What diff tools actually do
A diff tool compares two versions of a text and identifies the minimum set of changes (insertions and deletions) needed to transform one into the other. This is the Longest Common Subsequence (LCS) problem — finding the longest shared sequence of lines between two texts.
The result highlights:
- Lines added — present in the new version but not the old (typically shown in green)
- Lines removed — present in the old version but not the new (typically shown in red)
- Lines unchanged — present in both versions (shown without color, sometimes hidden for compactness)
Compare any two text files with the free diff checker — paste two versions and see the changes highlighted instantly.
Reading unified diff format
Git and most diff tools output "unified diff" format. Here's how to read it:
--- a/config.js
+++ b/config.js
@@ -12,7 +12,8 @@ const config = {
timeout: 5000,
- retries: 3,
+ retries: 5,
+ retryDelay: 1000,
debug: false,
}---and+++identify the old and new files@@ -12,7 +12,8 @@is the "hunk header" —-12,7means starting at line 12, showing 7 lines from the old file;+12,8means starting at line 12, showing 8 lines in the new file (one line added)- Lines starting with
-were removed - Lines starting with
+were added - Lines starting with a space are context (unchanged)
Diff tools and code review
Code review is fundamentally a diff review — you're examining what changed, not re-reading unchanged code. Pull request interfaces on GitHub, GitLab, and Bitbucket are all diff views with comment capabilities layered on top.
When reviewing code:
- Read the removed lines first. Understanding what was there before helps you evaluate whether the replacement makes sense and whether something important was accidentally deleted.
- Check the context lines. The unchanged lines around changes tell you where in the code the change lives — a change to
retries: 3inside a retry config object is very different from the same change inside an unrelated function. - Count the lines changed vs. lines affected. A one-line change to a function that's called 50 places in the codebase deserves more scrutiny than a 50-line change to a function called once.
When to use an online diff checker vs. git diff
Use git diff when:
- Comparing uncommitted changes to the last commit (
git diff HEAD) - Comparing two branches (
git diff main..feature-branch) - Comparing two commits (
git diff abc1234..def5678) - Working in a project with Git — it's built-in and the right tool
Use an online diff checker when:
- Comparing two versions of a text document, config file, or JSON payload that aren't in a Git repository
- Comparing content from two different systems (e.g., production config vs. staging config copied from a server)
- Comparing API responses before and after a change
- Sharing a visual diff with a non-technical stakeholder via screenshot
- Comparing two versions of a long document (legal text, contract revisions)
Diff for non-code use cases
Diff tools aren't only for code. Practical non-code uses:
- Contract and legal document review. When a contract is revised, a diff shows exactly what changed — faster and more reliable than reading the whole document twice.
- Configuration file changes. Comparing nginx.conf, .env, or JSON config files before and after a deployment or migration.
- Database query comparison. Checking if two SQL queries are identical or finding exactly where they differ.
- API response comparison. Comparing JSON responses from two environments to find discrepancies.
- Translated text review. Comparing source text and translated text side-by-side to ensure completeness.
Word-level vs. line-level diff
Standard diff operates at the line level — a line with any change is shown as deleted and re-added. This is unhelpful for changes in the middle of a long line:
- const baseUrl = "https://api.production.example.com/v2/users";
+ const baseUrl = "https://api.staging.example.com/v2/users";Only the word "production" changed, but the whole line is shown as replaced. Word-level (or character-level) diff highlights just the word that changed. The free diff checker supports word-level diffing, which makes single-word changes in long lines much easier to spot.
Related tools
- Free Diff Checker — compare two texts side-by-side with line and word-level diff highlighting
- Free JSON Formatter — format JSON before comparing for a clean diff
- Free SQL Formatter — format SQL queries before comparing
Written by Achraf A., founder of TheFreeAITools.