Skip to content

Text Diff

Text Diff Tool

Paste two pieces of text and see exactly what changed. Additions are highlighted in green, deletions in red, and unchanged lines fade into the background. Works on prose, code, JSON, YAML, log output, or any text where you need to track what moved between two versions.

Why Diffing Matters

Most editorial and engineering work is iterative: a draft, then a revision, then another. When the changes get past a sentence or two, eyeballing them stops working. A diff turns what changed? into a visual answer in under a second. The same principle drives version control systems like Git, but you don't need a repo or a commit history to compare two snippets — just paste and look.

This tool runs the diff entirely in your browser using a longest-common-subsequence algorithm. Nothing uploads, which matters if you're comparing draft contracts, internal documents, or anything covered by an NDA. For structural comparisons of formatted code, pair this with a JSON formatter or code beautifier first so whitespace doesn't dominate the diff.

How It Works

The diff operates line by line. Each line in the original is matched against the modified version using a longest-common-subsequence comparison, which finds the fewest added and removed lines. Lines present in both versions stay neutral; lines only in the original render as deletions; lines only in the modified version render as additions. The ignore whitespace toggle collapses leading/trailing space differences before comparison, useful when the only change is indentation. Ignore case treats Hello and hello as the same line.

Word-level highlighting inside changed lines is a stretch goal for a future revision. For now, line granularity catches the overwhelming majority of real review cases, and it scales to thousands of lines without slowing the browser.

Common Use Cases

Writers comparing draft and revised sections of a piece. Developers reviewing what a teammate changed before pulling it down. Lawyers running redlines on contract clauses (use the HTML entity encoder first if your clauses contain quotes that get mangled in transit). Sysadmins comparing config files between staging and production. Anyone reconciling two slightly-different exports from the same source system to find the field that drifted.

Worked example: the same edits through this tool and git

We generated a 2,000-line file and three edited versions on October 12, 2026. Each pair went through the tool's own diff function (Node 22) and through git diff --no-index with git's default Myers algorithm and with --diff-algorithm=histogram.

EditThis tool (added / removed lines)git, Myersgit, histogram
40 lines changed at random places40 / 4040 / 4040 / 40
A 50-line block moved from line 100 to line 150050 / 5050 / 5050 / 50
Every 10th line indented by 4 spaces200 / 200200 / 200200 / 200

The counts match git in all three cases. Two of them are worth reading closely:

How big can the texts be?

The comparison builds a full longest-common-subsequence table: one cell for every pair of lines, so its memory grows with lines × lines. In Node 22 the diff alone took about 0.05 s and 11 MB of heap for two 1,000-line texts, 0.7 s and 155 MB for 5,000 lines, and 2.3 s and roughly 850 MB of memory for 10,000. Up to a few thousand lines it is effectively instant. Near 10,000 lines on a phone or a low-memory laptop the tab may run out of memory. For very long files, compare sections, or use git diff --no-index file1 file2, whose Myers algorithm needs far less memory.

Sources

Checked on .

Frequently Asked Questions

What algorithm does this diff use?+
This tool uses a longest common subsequence (LCS) based algorithm for line-level comparison, then applies character-level diffing within changed lines to highlight exactly which characters were modified.
Can I compare code with this tool?+
Yes. The tool compares any plain text including source code, configuration files, JSON, HTML, and prose. Use the existing Diff Checker tool for syntax-highlighted code comparison.
Is there a size limit?+
No hard limit, but memory grows with the product of the two line counts. In our test the diff of two 5,000-line texts used about 155 MB and two 10,000-line texts about 850 MB, which can exhaust a phone or low-memory tab. For very long files, compare sections or use git diff --no-index.
Does this tool upload my text?+
No. All comparison happens in your browser. Your text never leaves your device.
What diff algorithm does the tool use?+
A longest-common-subsequence (LCS) comparison of whole lines, which finds a minimal set of added and removed lines, the same result Myers' algorithm (used by git) gives in terms of how many lines change. Two 10,000-line texts with 100 scattered changes took about 6 seconds in Chrome on our test machine and reported exactly the 80 additions and 80 removals planted.
Can I diff JSON objects semantically?+
Yes. Tick "JSON mode" and both sides are parsed, object keys are sorted at every level and the result is pretty-printed before comparing, so {"a": 1, "b": 2} and {"b": 2, "a": 1} show no differences and a changed value shows as one changed line. Array order still counts, because [1, 2] and [2, 1] are different JSON. If either side is not valid JSON, the tool says where it failed and compares the raw text instead.
How is whitespace handled?+
Two options. By default every character counts. Ignore whitespace trims the start and end of each line and treats any run of spaces or tabs as one space, so indentation and spacing changes are not reported. Ignore case compares lines without regard to upper or lower case. In both cases the result still shows your original text.
Can I export the diff in unified format?+
Yes. Copy unified diff puts the changes on your clipboard and the .diff button downloads them, in the unified format used by git diff and GNU patch (--- / +++ headers, @@ hunks, 3 lines of context). We checked 60 random edits: every exported diff applied cleanly with both patch and git apply and reproduced the modified text exactly. There is no HTML or summary export; the on-page view is the side-by-side version.

📖 Learn More

Related Article How to Compare Text Files: A Guide to Diff Tools →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service