📊 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

MarkMeaningDescription
+ lineAddedNew content was added
- lineDeletedContent was removed
~ lineModifiedContent was changed
  lineUnchangedNo 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

Developer Tools

Explore 80+ free online tools for developers. Base64, JSON, JWT, Regex, and more essentials in one place.

Quick Links

Developer Tools © 2025. All rights reserved.

Most tools run in the browser; tools that require network access only send data when you run them.

Diff | Developer Tools