Diff Checker

Compare two texts side-by-side with highlighted differences.

What It Does

The diff checker compares two blocks of text and highlights exactly what changed between them. Added lines are shown in green, removed lines in red, and unchanged lines are shown normally. It is useful for reviewing code changes, comparing configuration files across environments, checking document revisions, and spotting differences in API responses or log outputs.

How the LCS Algorithm Works

The tool finds the Longest Common Subsequence — the largest set of lines that appear in both texts in the same order. Everything not in the common subsequence is classified as either added or removed. This produces the minimal diff: the fewest changes needed to get from text A to text B.

Original:        Modified:
line 1           line 1
line 2     →     line 2 (edited)   ← changed
line 3           line 3
                 line 4 (new)      ← added

Common Use Cases

  • Comparing two versions of a config file (e.g., nginx.conf before and after a change)
  • Checking differences between .env files across staging and production
  • Reviewing document edits without tracked-changes support
  • Comparing JSON API responses to find what changed between two calls
  • Spotting accidental whitespace or encoding changes in source files

Tips

  • Normalize line endings before comparing — mixed CRLF/LF can cause every line to appear as changed
  • For JSON, pretty-print both sides first so structural changes show clearly on separate lines
  • Trim trailing whitespace to avoid false positives on lines that are semantically identical
  • For Git-managed files, use git diff or git diff HEAD~1 for history-aware comparisons

Frequently Asked Questions

What algorithm does the diff checker use?
The tool uses a Longest Common Subsequence (LCS) algorithm — the same approach used by Unix diff and Git. It finds the minimal set of additions and deletions needed to transform the original text into the modified text, producing the most readable diff output.
Can I compare code files, not just plain text?
Yes. The diff checker works on any text content — source code, configuration files, JSON, Markdown, SQL, and prose. Paste the content from any two text files and compare them. Syntax highlighting is not applied, but the line-level differences are clearly marked.
What do the colors mean in the diff output?
Green lines (or lines marked with +) are additions — they appear in the second text but not the first. Red lines (or lines marked with -) are deletions — they appear in the first text but not the second. Unchanged lines are shown in their original color.
Is this tool useful for reviewing code changes without Git?
Yes. If you have two versions of a file and no Git history, paste both into the diff checker to see exactly what changed. It's also useful for comparing clipboard snapshots, comparing API responses, or checking config file differences between environments.
How is a line-based diff different from a character-based diff?
A line-based diff (like Git's default) compares whole lines and marks a line as changed if any character in it differs. A character-based diff highlights the exact characters that changed within a line. For code review, line-based diffs are standard; character diffs are useful for prose editing where small word changes matter.