$ diff --check
text diff checker.
Compare two texts side by side. Added lines in green, removed lines in red.
original text
modified text
The tool implements a line-based LCS (Longest Common Subsequence) diff algorithm. It compares line by line and highlights additions in green and deletions in red.
The tool currently compares lines as-is. For code review, ensure consistent formatting before comparing.
Both text areas accept large inputs. Very large files may slow down the browser since all processing happens client-side.
How Diff Algorithms Work
Text diffing finds the minimum set of changes (insertions, deletions) to transform one string into another. Different algorithms optimize for different goals:
Algorithm Comparison
| Algorithm | Time | Output Quality | Used By |
|---|---|---|---|
| Myers | O(n*m) | Good (minimal edits) | Git, most diff tools |
| Patience | O(n*m) | Better for code | Git (--diff-algorithm=patience) |
| LCS | O(n*m) | Optimal but slow | Textbooks, small inputs |
| Histogram | O(n*m) | Best for code | Git default (2.9+) |
Line-Level vs Word-Level vs Char-Level
Line diff: shows whole lines changed
Word diff: shows which words within a line changed
Char diff: shows individual character changes (most granular)
// Example — char-level diff of "color" → "colour":
// co- -l +ou- r
Code review tip: Use word-level or char-level diffing for long lines (minified code, single-line configs). Line-level diffing on a 500-char line just shows the whole line as changed.
learn more in our detailed guide.
→ read the guide