Text Diff Checker

Compare two texts and see the differences with character, word, or line-level precision.

Comparison Options
1 lines • 0 chars
1 lines • 0 chars
Runs entirely in your browser. No uploads. Your files stay private.

How the Text Diff Tool Computes Changes

Text Diff implements the Myers diff algorithm in pure JavaScript — the same algorithm used by `git diff`, GNU diff, and most code review tools. Myers finds the shortest edit script (the smallest number of insertions and deletions) that transforms the first input into the second. The implementation here runs in O((N+M)D) time where N and M are the input lengths and D is the edit distance, which is fast for typical document edits where most lines are unchanged.
Diffing happens at two levels. Line-level diff splits both inputs on newline characters and runs Myers over the line arrays. Word-level diff splits on whitespace using the regex /(\s+)/ which preserves the whitespace tokens so that re-joined output matches the original. Word-level is used to highlight changes inside a modified line, while line-level decides which lines are unchanged versus modified.
The classic Myers algorithm is O(ND) and uses a V-array indexed by k-line numbers (the diagonal in the edit graph). The implementation walks from start to end finding the furthest reaching point on each diagonal, then back-traces to recover the actual edit script. For typical edits — a few changed lines in a long document — this completes in well under one hundred milliseconds even for thousand-line inputs.
Performance degrades when the two inputs are very different (high D), because Myers explores more diagonals. Pasting two completely unrelated documents and asking for a diff can hit O(NM) in the worst case, which freezes the tab on multi-thousand-line inputs. This is a property of the algorithm, not a bug. For unrelated texts, the result is also not informative.
Whitespace-insensitive and case-insensitive modes do not change the diff algorithm itself; they normalize both inputs before passing them to Myers. Whitespace mode collapses runs of whitespace to a single space and trims; case-insensitive lowercases both inputs. Because the original text is preserved separately, the highlighted output still shows the verbatim characters even when the comparison key was normalized.
Two view modes are available. Unified shows one column with green plus markers for additions and red minus markers for deletions, mimicking the output of git diff. Side-by-side renders two columns with synchronized scrolling. Both views compute against the same edit script — switching modes does not retrigger the diff calculation, only the renderer.
Output is exposed via Copy, Download (as a plain-text patch in the unified format), and a stats panel that counts added, removed, and unchanged lines. Everything runs synchronously in the browser tab. There is no upload — your contracts, source code, and pre-publication drafts stay local even when computing the diff against a server-fetched template would be more convenient.

Common Use Cases

01

Contract redline review

Compare two versions of a contract clause-by-clause to identify exactly which sentences and definitions changed before re-signing.

02

Code review diff

Paste two snippets of source code and get a Myers-quality line-and-word diff without setting up a Git workflow for casual review.

03

Editorial revision check

Diff two drafts of an article to confirm what an editor changed and whether their edits were applied correctly.

04

Configuration drift detection

Compare a known-good config file against a production version to spot drift, accidental edits, or missing entries.

Frequently Asked Questions

Myers' algorithm, the same one that powers `git diff`, GNU diff, and most code-review tools. It finds the shortest sequence of insertions and deletions that transforms input A into input B. The implementation here is in pure JavaScript, so no external library is loaded — it ships in the page bundle.
Line-level diff splits both inputs on newlines and Myers-compares the resulting arrays — this is what shows up in the green/red gutter. Word-level diff splits on whitespace and runs inside a modified line to highlight which words changed, which is more granular than 'this whole line is different'.
Yes for typical document edits where most content is unchanged — Myers is O((N+M)D) where D is the edit distance, so a few hundred changed lines in a five-thousand-line file completes in under a second. Pasting two completely unrelated texts produces a near-O(NM) workload and can freeze the tab on multi-thousand-line inputs.
It normalizes both inputs by collapsing runs of whitespace to a single space and trimming each line before passing to Myers. This means trailing-space-only changes and indentation-only changes show as unchanged. The displayed text is still the verbatim original — only the comparison key is normalized.
Line numbers are tracked separately for each input. An added line gets a new-side line number; a removed line gets an old-side line number; an unchanged line gets both. The renderer shows them in two gutter columns so you can correlate edits with the original document positions.
Yes. The download button produces a unified-format patch (similar to what `git diff` outputs) with @@ hunk headers, plus and minus prefixes per line, and surrounding context. You can apply this patch with `patch` or `git apply` if both files are saved to disk first.
Internally the diff splits on /\n/ which catches LF (Unix and macOS) but treats CRLF (Windows) as a CR character at the end of each line. If your inputs have different line endings, every line will appear modified. Run both inputs through the Text Cleaner first with line-ending normalization on.
No. The Myers implementation runs synchronously inside the browser tab. There is no fetch call and no analytics on the input. You can disconnect from the network after the page loads and the tool keeps working — useful for diffing material under embargo or NDA.
Myers' algorithm does not detect block moves. A paragraph that moves from the top to the bottom appears as one deletion and one addition with the same content. Block-move detection requires a different algorithm (Patience diff or histogram diff with move detection); use a tool like `git diff --color-moved` for that.
Yes. Both inputs are lowercased only for the purpose of computing the Myers comparison key. The displayed text is the verbatim original from each input, so a line that differs only in capitalization will appear unchanged in the gutter but still display its original case.

Advertisement