IT Tool

Free Diff Checker Online

Compare two texts line by line and see additions, deletions, and unchanged lines highlighted, with separate original and modified line numbers.

Instant 100% Client-Side No Login
PROCESSINGLOCAL
LIMITNONE
PRIVACYBROWSER-ONLY

Original

Modified

A diff is the shortest edit script between two versions

Comparing 2 versions of a file by eye is slow and unreliable past a dozen lines. A diff tool automates it by computing the smallest set of insertions and deletions that turns the first text into the second, then showing those edits in place. The mental model that matters is the edit script: an ordered list of 3 operation types, keep this line, delete this line, add this line, that replayed against the original reproduces the modified version exactly. Everything a diff viewer shows, the green additions marked with a leading +, the red deletions marked with a leading -, the unchanged context with a blank marker, is just that script rendered with color. Editing 1 word in a 200-line file yields an edit script of length 2, 1 delete and 1 add, not 200. This tool works at line granularity, the same unit Git and code review tools use, because for source code and config files a line is the natural atom of change. The idea is old: the Unix diff utility shipped in 1974 with the 5th Edition of Unix, written by Douglas McIlroy and James Hunt, and its line-oriented output became the basis of the patch format still used 50 years later.

The engine underneath is the Longest Common Subsequence. The LCS of 2 sequences is the longest run of elements appearing in the same order in both, though not necessarily adjacent. Find the LCS and the answer falls out: every line in the LCS is unchanged, every line in the original but not the LCS was deleted, and every line in the modified version but not the LCS was added. The classic way to compute it is dynamic programming, filling an m by n grid where m and n are the line counts of the 2 inputs, each cell holding the LCS length of the prefixes up to that point. The recurrence is 1 rule: if the 2 lines match, the cell is 1 plus the diagonal neighbor, otherwise it is the larger of the neighbor above and the neighbor to the left. That grid costs O(m by n) in both time and memory, which is why this tool caps each side at 4000 lines: a 4000 by 4000 grid is 16 million cells, roughly 128 MB at 8 bytes per number, and past that a browser tab starts to stutter. A refinement due to Hirschberg in 1975 computes the same LCS in O(m by n) time but only O(m plus n) memory by recursing on the midpoint, the trick that lets command-line diff handle files of 100000 lines or more without exhausting RAM.

Why real diff tools use Myers, not the raw LCS grid

The plain O(m by n) matrix is correct but wasteful, because most real edits are small relative to the file. In 1986 Eugene Myers published the algorithm Git uses by default, which reframes the problem as the shortest path through an edit graph and runs in O(N by D) time, where N is the combined length of the 2 files and D is the size of the edit, the number of lines that actually changed. When 2 files differ by only 5 or 10 lines, D is tiny and Myers is far faster than the full grid, which is exactly the common case in version control where 1 commit touches a small fraction of the codebase. This tool uses the straightforward LCS matrix rather than Myers because at the 4000-line ceiling the difference is imperceptible and the matrix is easier to reason about; the output, the minimal set of adds and deletes, is identical either way. Git exposes 4 diff algorithms, myers, minimal, patience, and histogram, and defaults to Myers; patience, added around 2010, picks low-frequency common lines as anchors to produce more readable hunks when large blocks move.

Line numbers, and the trap of a single counter

A subtle correctness point separates a real diff view from a naive 1: line numbers. When a line is inserted, every following line in the modified file shifts down by 1, so a given line of text no longer sits at the same number in both versions. A viewer that prints 1 running counter down the merged output gives a number that matches neither file once any edit appears. This tool shows 2 gutters, the original line number and the modified line number side by side, and leaves the cell blank on the side where the line does not exist: an added line has no original number, a deleted line has no modified number. That is the same convention Git's unified diff uses in its @@ hunk headers, a line like @@ -12,7 +12,9 @@ that states the changed block starts at line 12 and spans 7 lines in the old file and 9 in the new, so a patch can be applied at the right offset. Those hunks also carry 3 lines of unchanged context above and below by default, enough for a human or the patch command to locate the block even if surrounding lines have shifted.

What this tool compares, and what it does not

Everything runs in your browser: the 2 texts are split on newlines, compared, and rendered locally, so no source code, config, or document is uploaded or stored. 2 toggles change what counts as a match without changing what is shown. Ignore whitespace collapses runs of spaces and tabs and trims each line before comparing, so a reindented block reads as unchanged rather than as a wholesale rewrite, useful when a formatter has touched a file. Ignore case folds letters to lowercase for the comparison, so 2 lines differing only as Error and error count as 1 unchanged line. Both affect matching only; the original text is always displayed verbatim. The comparison is line-level, so a 1-character change inside a long line marks the whole line as removed and re-added rather than highlighting the single character, which is the right trade for code but coarser than a word-level or character-level diff would be for prose. The tool does not do 3-way merges, does not resolve conflicts, and does not understand syntax: it compares text as text, so a change that is semantically trivial to a compiler, reordering 2 independent functions, still shows as 1 delete plus 1 add.

How to Use

1

Paste your original text on the left and the modified text on the right.

2

Differences are highlighted automatically below as you type.

3

Green with a + is added, red with a - is removed, plain is unchanged.

4

Toggle "Ignore whitespace" or "Ignore case" to skip formatting-only changes.

Features

Line-by-line comparison using the Longest Common Subsequence algorithm
Separate original and modified line-number gutters, Git-style
Ignore-whitespace and ignore-case toggles for formatting-only edits
Live counts of added, removed, and unchanged lines
100% client-side — your text is never uploaded

Common Questions

About Diff Checker

Compare two code snippets, config files, or any text and see additions, deletions, and unchanged lines highlighted line by line, with separate original and modified line-number gutters like Git. Uses the Longest Common Subsequence algorithm, with ignore-whitespace and ignore-case toggles for formatting-only changes. Runs entirely in your browser.

Also known as: compare text, text difference, diff tool, compare two files, text compare, code diff, file compare, find differences, diff online, compare code, json diff, side by side diff, text comparison, git diff online.

Processing Note

Diff Checker runs in your browser, so the input you enter is processed locally on this page and is not uploaded to a ToolMintX account.

Tool Limits

IT tools provide quick diagnostics and transformations. They cannot see every private network, deployment setting, proxy, firewall, or production edge case.

Explore More