Text Diff Checker

Compare two texts side by side. Highlight added, removed, changed lines for code review, content comparison.

What is text diff?

Text diff (difference) compares two pieces of text and shows what’s added, removed, or unchanged. It’s the core technology behind version control (Git, SVN), document comparison (Word’s track changes), code review tools (GitHub PR review), proofreading (compare draft to revised version), and many more. The algorithm finds the longest common subsequence (LCS) between two texts and identifies minimal changes. This tool shows line-by-line diff with color coding: green for additions, red for deletions, neutral for unchanged. Useful for: comparing code revisions, checking what changed in contracts, reviewing edits to articles, tracking config file changes, and learning what someone modified.

How to use this tool

  1. Paste original text — Left side – the ‘before’ version.
  2. Paste modified text — Right side – the ‘after’ version.
  3. View diff highlights — Below shows line-by-line comparison: green (added), red (removed), gray (unchanged).
  4. Check statistics — Counts of added, removed, unchanged lines for quick overview.

Diff algorithm

The Longest Common Subsequence (LCS) algorithm:

  1. Build a 2D table of size (m+1) × (n+1) where m,n are line counts
  2. Fill table using dynamic programming: if lines match, value = top-left + 1. Else value = max(top, left)
  3. Backtrack from bottom-right to construct the diff

Result categorizes each line as:

  • = (unchanged) – line in both texts
  • – (removed) – line only in original
  • + (added) – line only in modified

Line ordering preserved, so output shows logical flow of changes.

Examples

Code review: See what your colleague changed in their pull request – additions in green, removals in red, makes review faster.

Document revision: Compare draft v1 to v2 – quickly spot what got rewritten without re-reading the entire document.

Configuration tracking: Two versions of nginx.conf – immediately see what setting changed.

Translation review: Original text vs translator’s output – line-by-line check.

Contract negotiation: Compare drafts to track changes proposed by counterparty.

Tips & best practices

  • For best results, both inputs should have similar structure (same line endings, similar formatting)
  • Line-level diff (this tool) works best for documents and code. Word-level diff better for sentences
  • If your files have different line endings (CRLF vs LF), normalize first – false diffs everywhere otherwise
  • Large files (1000+ lines) may slow the algorithm – O(n×m) complexity
  • Use git diff for actual code/config tracking – this tool is for ad-hoc comparison
  • For diffing JSON, use a JSON-aware diff tool that ignores key order
  • When sharing diffs, copy the colored output as image (screenshot) or use Markdown blockquote

Limitations & notes

Line-based diff only – doesn’t show character-level changes within lines. For word-level diff, use specialized tools like git diff –word-diff. Doesn’t handle very large files efficiently due to O(n×m) complexity. For binary files (images, PDFs), this won’t work – use binary diff tools.

Frequently Asked Questions

What’s the difference between line diff and word diff?

Line diff: compares whole lines as units. If you change one word in a long line, the entire line is shown as changed. Word diff: highlights just the changed words within lines – more precise. This tool does line diff (faster, simpler).

Does the order of lines matter?

Yes – the diff algorithm finds longest common subsequence, which preserves order. If you reorder lines, the diff will show many additions and removals even though content is same.

How is this different from git diff?

Same fundamental algorithm but git tracks files in repository. This tool is for ad-hoc text comparison without needing git setup. For tracking actual code changes, use git. For one-time comparison, use this tool.

What if my texts have different line endings?

Normalize first. Notepad++ has ‘Convert to Unix line endings’ option. Or use online converters. Otherwise the diff shows every line as changed (because invisible CRLF vs LF differs).

Can I diff JSON files?

Yes but limited – line diff shows JSON as text without understanding structure. If key order differs but content same, diff shows changes. For structural JSON diff, use specialized tools like jsondiffpatch.

How are conflicts resolved?

Diff just shows changes – doesn’t merge. For merging with conflicts, use 3-way merge tools (git merge, beyond compare). This tool is for visualization, not merging.

What’s the maximum file size?

Browser-based, so memory limits apply. Files up to several MB work fine. Very large files (over 100 MB) may freeze browser. For large file diff, use desktop tools like Beyond Compare or command-line diff.

Related tools

Word Counter · Code Minifier · Markdown to HTML

Copied to clipboard