What is a Diff?
A "diff" (short for difference) is a comparison between two pieces of text that shows exactly what was added, removed, or left unchanged. The concept originated in the Unix world with the diff command, first released in 1974 as part of the Fifth Edition of Unix. Today, diffs are the backbone of version control systems like Git, Mercurial, and SVN.
When you compare two files, the diff algorithm identifies the longest sequence of lines that appear in both versions (the Longest Common Subsequence). Lines not in this shared sequence are flagged as additions or deletions. This approach produces a minimal, readable summary of changes.
How Diff Algorithms Work
The most common diff strategy is based on the Longest Common Subsequence (LCS) problem. Given two sequences of lines, the algorithm builds a matrix of size O(n x m) where n and m are the line counts of each text. It then backtracks through the matrix to find the optimal alignment.
Lines present in the LCS are marked as unchanged. Lines in the original but not in the LCS are marked as removed. Lines in the modified text but not in the LCS are marked as added.
More advanced algorithms like Myers' diff (used by Git) optimize this further to O(n + m + d^2) where d is the number of differences, making them faster when changes are small. Our implementation uses the classic O(n x m) approach which is easy to understand and works well for typical document sizes.
Common Use Cases
Code Review
Compare two versions of source code to review pull requests, spot bugs, or understand what changed between releases.
Document Comparison
Check differences between drafts of contracts, articles, or any written content to ensure every edit is intentional.
Configuration Auditing
Compare server configs, environment files, or YAML/JSON settings to catch unintended changes before deployment.
Database Migrations
Diff SQL schemas or migration files to verify that database changes match expectations.
Merge Conflict Resolution
Paste conflicting versions side by side to manually resolve Git merge conflicts with full context.
Content Versioning
Track changes in blog posts, documentation, or translations across different versions.
Frequently Asked Questions
A diff checker is a tool that compares two blocks of text and highlights the differences between them. It shows which lines were added, removed, or left unchanged, making it easy to spot changes at a glance.
This tool uses the Longest Common Subsequence (LCS) algorithm. It finds the longest sequence of lines common to both texts, then marks any lines not in that sequence as additions (in the modified text) or deletions (in the original text). This is the same foundational approach used by Git and other version control systems.
Yes. Everything runs 100% in your browser using JavaScript. Your text is never uploaded to any server, stored, or shared. Close the tab and it is gone.
Absolutely. The diff checker works with any plain text including source code in any programming language, configuration files, SQL queries, JSON, YAML, and more.
Green lines were added in the modified text. Red lines were removed from the original text. Lines with no highlight are unchanged between the two versions.
When enabled, differences in spaces, tabs, and trailing whitespace are ignored during comparison. This is useful when you only care about meaningful content changes, not formatting.
There is no hard limit, but because the LCS algorithm runs in your browser, very large texts (tens of thousands of lines) may take a moment to process. For typical documents and code files it is instant.
Yes. Paste the original version in the left panel and the updated version in the right panel, then click Compare. You will see exactly which lines changed, which is perfect for reviewing pull requests, patches, or any code changes.