Text Diff — Compare Two Texts Online
Spot the differences between two texts line-by-line. Additions in green, deletions in red, with optional ignore-whitespace and ignore-case. Runs entirely in your browser.
| 1 | 1 | function greet(name) { | |
| 2 | − | console.log("Hello " + name); | |
| 3 | − | return true; | |
| 2 | + | console.log(`Hello, ${name}!`); | |
| 3 | + | return name.length > 0; | |
| 4 | 4 | } | |
| 5 | 5 | ||
| 6 | − | const tools = ["qr", "json", "image"]; | |
| 7 | − | greet("world"); | |
| 6 | + | const tools = ["qr", "json", "image", "diff"]; | |
| 7 | + | greet("WRRK"); |
About this tool
WRRK's text diff is a fast, browser-only line-by-line comparison tool. It splits each input into lines, builds a Longest Common Subsequence matrix, and reconstructs the canonical diff: each line is either common to both sides, only in the original (deleted), or only in the modified side (added). The output is rendered as a unified diff with both sets of line numbers, color highlighting, and a small counter at the top showing how many lines were added, removed, or unchanged.
Two normalization options keep the diff signal clean. Ignore whitespace collapses runs of spaces and trims line edges before comparing — useful when an editor reformatted a file and you want to see only the substantive changes. Ignore case lower-cases both sides before comparing — useful for comparing identifiers, environment values, or copy that may have been retitled. The tool runs comfortably up to about 5000 lines per side; beyond that, switch to git diff for performance.
How to compare two texts (5 steps)
- Paste original text. Drop the original or older version into the left textarea.
- Paste modified text. Drop the changed or newer version into the right textarea.
- Optional: ignore whitespace or case. Use the toggles when only formatting or capitalization changed and you want a noise-free diff.
- Read the diff. Added lines highlight in green, removed lines in red, unchanged lines stay neutral. Line numbers show on each side.
- Swap or sample. Click Swap to flip left and right, or Sample to load an example and see the layout.
Use cases
- Comparing two versions of a contract or NDA before signing
- Spotting accidental edits between two copies of a config file
- Reviewing a redline from a counterparty
- Comparing API response payloads between two environments
- Reconciling two CSV exports for missing rows
- Checking what your IDE's autoformatter actually changed
- Diffing two prompt templates side-by-side during prompt iteration
Frequently asked questions
+−What does this text diff tool do?
It compares two text inputs line-by-line and shows you exactly what changed: lines added in green, lines removed in red, lines unchanged in plain. Useful for spotting differences between two versions of code, configuration, contracts, or any text content.
+−How does the diff algorithm work?
The tool uses an LCS (Longest Common Subsequence) line-diff algorithm — the same approach used by Git, Mercurial, and most diff tools. It finds the longest sequence of lines that appears in both inputs, then marks everything else as added or removed.
+−Does the diff handle large files?
Up to 5000 lines per side runs comfortably in the browser. Beyond that, the LCS matrix grows quadratically and would slow your browser. For huge diffs, use git diff or a desktop tool.
+−What does 'ignore whitespace' do?
It collapses runs of whitespace and trims line ends before comparing — so 'foo bar' and 'foo bar' are treated as identical. Useful when only formatting changed and you want to focus on real edits.
+−Is the text sent to a server?
No. The diff is computed entirely in your browser. Both inputs and the result stay on your device — safe for confidential drafts, contracts, code, or production configs.
+−Can I diff JSON or code with this tool?
Yes, but format both inputs the same way first. Inconsistent indentation will produce a noisy diff. For JSON, run both inputs through a formatter (try our JSON Formatter) so identical structures produce identical lines.
+−Why are some 'changed' lines shown as remove + add instead of one line?
A pure line-diff treats every line as atomic — when a line is modified, the original line is shown as removed and the new line as added. This makes the algorithm fast and predictable; word-level highlighting is a separate, more expensive layer.