Diff Checker

Compare two blocks of text side by side and see the differences highlighted with color-coded output. Uses the LCS (Longest Common Subsequence) algorithm for accurate line-by-line comparison.

How to Use the Diff Checker

Paste your original text into the left panel and the modified text into the right panel, then click "Compare." The tool will analyze both texts line by line using the Longest Common Subsequence (LCS) algorithm and produce a unified diff output below. Added lines appear in green, removed lines appear in red, and unchanged context lines are shown in grey. A statistics bar summarizes the total number of added, removed, and unchanged lines at a glance. Use the "Swap" button to quickly exchange the two inputs, and "Clear" to reset everything.

What Is a Diff?

A "diff" is the result of comparing two sequences of text — typically two versions of the same file — to identify exactly what changed between them. The concept was pioneered in the early 1970s at Bell Labs when Douglas McIlroy and James Hunt developed the Unix diff utility. Today, diffs are a cornerstone of software engineering workflows. Every time you review a pull request, merge a branch, or inspect a commit in Git, you are reading diffs. The standard "unified diff" format shows a few lines of surrounding context (prefixed with a space) to orient the reader, lines that exist only in the original (prefixed with -), and lines that exist only in the modified version (prefixed with +).

The LCS Algorithm

This tool uses the Longest Common Subsequence (LCS) algorithm to compute differences. LCS finds the longest sequence of lines that appear in both texts in the same order, though not necessarily contiguously. The lines that are not part of the LCS are the actual changes — additions and deletions. This approach is far more accurate than a naive line-by-line positional comparison, because it correctly handles insertions and deletions in the middle of a document without causing every subsequent line to appear as changed. The LCS algorithm runs in O(n × m) time, where n and m are the number of lines in each text. For most practical document sizes, this executes in milliseconds directly in your browser.

Options Explained

Ignore whitespace normalizes all whitespace before comparison. Leading and trailing spaces are trimmed, and multiple consecutive whitespace characters are collapsed to a single space. This is useful when comparing code that may have been reformatted with different indentation styles or when trailing whitespace was added or removed. Ignore case converts both texts to lowercase before comparison, which is helpful when case changes are not semantically meaningful — for example, comparing SQL queries or configuration files where casing varies.

Common Use Cases

  • Code review: Paste the old and new versions of a function to quickly see what changed without needing a full Git setup.
  • Configuration audits: Compare two versions of a server config, Dockerfile, or CI pipeline definition to spot unintended changes.
  • Document editing: Writers and editors can compare drafts to track revisions in plain-text manuscripts, markdown files, or translated content.
  • Debugging: Compare program output from two different runs (e.g., expected vs. actual) to pinpoint divergences.
  • Database migrations: Diff two SQL schema dumps to verify that a migration script produces the intended changes.

Privacy and Performance

All comparison logic runs entirely in your browser — no text is ever uploaded to a server. This makes the tool safe for comparing proprietary source code, confidential documents, API keys, or any other sensitive content. Because the LCS computation is performed in JavaScript on your device, results appear instantly even for texts containing thousands of lines.