📊 Text Diff Checker
Compare differences between two texts
What is Diff?
Why use diff?
Diff highlights additions, deletions, and modifications between two texts or files. It quickly surfaces changes for code reviews, document comparison, and config validation.
Version control systems like Git and SVN rely on diff algorithms to track commits. Developers use diffs to understand impact, avoid mistakes, and review faster.
When to use it
- Code review: inspect Pull Request changes
- Config compare: dev/prod config differences
- Document versioning: before/after comparison
- API response compare: expected vs actual
- Migration checks: before/after data moves
- Merge conflicts: inspect both sides in Git
Practical examples
Example 1: Config file comparison
Dev environment (config.dev.json)
{
"database": "dev_db",
"port": 3000,
"debug": true
}Prod environment (config.prod.json)
{
"database": "prod_db",
"port": 8080,
"debug": false
}Diff: database, port, and debug values differ
Example 2: Code change
- function calculateTotal(items) {
+ function calculateTotal(items, discount = 0) {
let total = items.reduce((sum, item) => sum + item.price, 0)
+ total = total * (1 - discount)
return total
}Signature updated and discount logic added
Diff notation
| Mark | Meaning | Description |
|---|---|---|
| + line | Added | New content was added |
| - line | Deleted | Content was removed |
| ~ line | Modified | Content was changed |
| line | Unchanged | No change (context) |
Caveats
- Whitespace/indentation: whitespace-only differences still count. Run a formatter first.
- Line endings: beware of Windows (CRLF) vs Unix (LF).
- Large rewrites: if everything changes, the diff is less meaningful.
- Binary files: images/PDFs cannot be compared with line diff.
- Encoding: different encodings can make identical content appear different.
Diff algorithms
Common diff algorithms:
- • Myers Diff: widely used; Git default.
- • Patience Diff: better for structural code changes.
- • Histogram Diff: improved Patience variant with performance gains.
- • Word Diff: compares at word level instead of lines.
Learn more
Ferramentas relacionadas
Ver todas as ferramentas de Rede e DevOpsVeja ferramentas que combinam bem com esta.