Skip to content

Text Diff

Two textareas in, unified diff out. Browser-only, no upload.

Compare two versions of text and see exactly what changed. Additions are highlighted in green, removals in red, unchanged lines pass through. The diff is line-level (not character-level) — same convention as git diff and diff -u. Pure JavaScript longest-common-subsequence algorithm running entirely in your browser.

+1 1 ·2line-level diff · longest-common-subsequence
The quick brown fox
jumps over the lazy dog.
+leaps over the sleeping dog.
Woof.

Line-level diff. To diff at the word or character level, split the input differently before calling the underlying lib. The algorithm is O(m·n) — fine for thousands of lines, slow above ~50,000.

How to use

  1. Paste the old text

    The earlier version of whatever you're comparing — a draft, an email reply, a config file.

  2. Paste the new text

    The newer version. As you type, the diff recomputes.

  3. Read the result

    Green lines were added in the new version. Red lines were in the old version but removed. Unchanged lines display in dim text.

Frequently asked questions

Is this the same algorithm as git diff?
Same family — Myers' algorithm based on longest-common-subsequence. git uses a more optimised variant for large files with line-level heuristics; for typical text comparison the output is identical.
Can I diff at the word or character level?
Not in the UI yet. The underlying library accepts any string-split function, so word-level and char-level diffs are a one-line change. Coming in a future enhancement.
What's the max input size?
The algorithm is O(m·n) in time and memory. Up to ~5000 lines each side is comfortable; above ~50,000 lines the page will slow noticeably.
Does the tool store my text?
No. Every diff runs in your browser; nothing is sent to a server or logged.

About

Longest common subsequence

Given two sequences, the LCS is the longest sequence appearing in the same relative order in both — though not necessarily consecutively. ABCDE vs ACDEF have LCS ACDE. The diff algorithm derives the operation list (keep / delete / insert) from the LCS by walking both inputs and emitting whichever isn't in the common subsequence.

Why line-level by default

Line-level diffs are typically what humans want to read — they preserve the unit of meaning in code and prose. Character-level diffs are visually noisy and only useful when you're tracking truly fine-grained changes (e.g., copy-editing single-word substitutions).