Skip to main content
Home/Blog/Diff Checker - Text Comparison Tool
Developer ToolsDevelopment & Utilities

Diff Checker - Text Comparison Tool

Compare two texts side-by-side with line-by-line diff highlighting and word-level differences

Diff Checker - Text Comparison Tool

A diff checker compares two blocks of text and highlights every line, word, or character that differs — additions in green, deletions in red — so you can see exactly what changed between two versions without reading both from scratch. Under the hood it computes the Longest Common Subsequence of the two inputs: the longest sequence of lines shared by both versions in the same order, even when those lines are not adjacent. Anything outside that common subsequence is reported as inserted or deleted, which is how the tool turns "these two files are different" into a precise, color-coded, line-by-line map of the change.

That's the summary an AI Overview can give you. What it can't do is run the comparison on your two versions. So paste them below — this diff checker runs entirely in your browser, uploads nothing, and highlights the differences instantly. Then keep reading for the part the summary skips: how to pick line-level vs word-level, when to ignore whitespace, and which diff algorithm produces the cleanest review.

Online Diff Checker & Code Compare

Compare text, code, and config files side by side with syntax highlighting. See additions, deletions, and changes instantly.

Open the full Online Diff Checker & Code Compare tool →
Loading interactive tool...

How a diff engine decides what changed

A diff is not a character-by-character subtraction. The engine looks for the Longest Common Subsequence (LCS) — the biggest set of lines shared by both files in the same order — and treats those as anchors. Everything between the anchors is either something the old file had and the new one dropped (a deletion) or something the new file gained (an addition). The diagram below shows the alignment: matching lines stay put, and only the genuinely-changed lines get colored.

How a diff aligns two versions using the Longest Common Subsequence The original and modified text are lined up on their shared lines; unmatched lines are marked as a deletion in red or an addition in green. Original Modified const port = 3000; let cache = null; start(port); export default app; const port = 3000; start(port); log('ready'); export default app;

− deletion (not in Modified) + addition (new in Modified) — — — matched lines (LCS anchors) — — — Only unmatched lines are colored; everything anchored is "unchanged".

Because a change can be described in more than one valid way, two diff tools can color the same edit differently and both be correct — after you apply either result the files are identical. That freedom is exactly what the different algorithms exploit.

Diff algorithms compared

Git, GitHub, and most modern tools default to Myers' algorithm (Eugene Myers, 1986 — "An O(ND) Difference Algorithm and Its Variations"), but you can switch. The trade-off is between finding the mathematically shortest edit and finding the most readable one for a human reviewer.

AlgorithmWhat it optimizes forBest forWeakness
Myers (default)Shortest edit script (fewest inserts/deletes)General-purpose, fast on almost anythingCan align on repeated/blank lines and split changes oddly
MinimalAbsolute smallest diff, even if slowTiny files where you want the theoretical minimumSlower; rarely worth it in practice
PatienceAnchoring on lines unique to each sideRefactors, moved blocks, source code reviewSlightly slower than Myers
HistogramPatience's idea, tuned for speed and qualityThe best default for reviewing code changesMarginally more complex; still fast
Which should I use?—Reviewing code: try histogram. Everything else: the myers default is fine.—

Switch algorithms in Git with git diff --diff-algorithm=histogram, or set it permanently with git config --global diff.algorithm histogram.

Line-level vs word-level: a decision matrix

The single biggest quality lever in a diff is granularity. Line-level highlights whole lines; word-level highlights only the changed tokens inside a line. Neither is "better" — they suit different content.

Your contentUse this granularityWhy
Source code, config files (JSON, YAML, TOML)Line-levelLine boundaries are meaningful; a changed line usually means a changed statement
Prose, articles, documentationWord-levelA one-word edit shouldn't repaint the whole paragraph
Legal contracts, policy documentsWord-levelYou need to see the exact clause that moved, not the whole section
Long single-line strings (minified JS, URLs, CSV rows)Character-levelThere are no line breaks to anchor on
Reformatted code (reindented, tabs→spaces)Line-level + ignore whitespaceCollapses cosmetic noise so real logic changes surface
Data files where key order varies (JSON/YAML)Normalize first, then line-levelSort keys and pretty-print both sides so equivalent data doesn't read as different

Reading unified diff format

When you copy a diff out of Git or diff -u, you get unified diff format — the same thing patch tools and code review platforms consume. Each change block is a "hunk" with a header telling you where it lands:

@@ -12,4 +12,5 @@ function start(port) {
   const app = express();
-  let cache = null;
   app.listen(port);
+  log('ready');
+  metrics.mark('boot');
   return app;

The header @@ -12,4 +12,5 @@ means: in the old file the hunk starts at line 12 and spans 4 lines; in the new file it starts at line 12 and spans 5 lines. Lines with - were removed, lines with + were added, and unprefixed lines are unchanged context (usually three lines each side) that helps patch locate the hunk even if surrounding line numbers drifted. This is why a unified diff can be applied to a slightly different version of a file than the one it was generated from.

Common use cases

  • Code review — Compare two versions of a source file to see what a change actually touched before you merge it. Ignore whitespace to strip out reformatting noise, and reach for a histogram diff on gnarly refactors.
  • Document and contract comparison — Track revisions between drafts of an agreement, article, or spec. Word-level highlighting shows the exact clause that changed.
  • Configuration drift — Diff a known-good config against what's running in production to spot the one changed value that broke a deployment.
  • Debugging "identical" outputs — When two runs "should" produce the same output but don't, a diff pinpoints the byte that differs — a trailing newline, a locale-formatted number, a reordered key.
  • Verifying copied content — Compare an original against a suspected duplicate to see precisely which passages match and which were altered.

Need expert code review?

Our development team provides professional code reviews, security audits, and quality assurance for your applications.

Request Code Review

Frequently Asked Questions

Find answers to common questions

Line-level diff highlights entire lines that differ between versions. Word-level diff (also called character-level) shows exactly which words or characters changed within a line, providing more granular detail.

Yes, most diff checkers offer an option to ignore whitespace, tabs, and line ending differences. This is useful when comparing code that has been reformatted but functionally unchanged.

Yes, this diff checker runs entirely in your browser. No text is uploaded to any server, ensuring your data remains completely private and secure on your device.

Building Something Great?

Our development team builds secure, scalable applications. From APIs to full platforms, we turn your ideas into production-ready software.