CruxDevCruxDev Tools Prompts
text Utility • Zero-Server Privacy • 100% Client-Side

Text Diff & Merge

Compare two text blocks line-by-line with color-coded additions, deletions, and modifications.

Overview

Compares two blocks of text with a proper longest-common-subsequence diff engine and highlights the exact words that changed inside a line, not just the line itself. It offers unified and side-by-side views, counts added, removed and modified lines, reports a similarity percentage, and warns when a difference is only line endings — all computed in the browser with deliberate performance caps.

How It Works

Paste the older text into Original and the newer into Changed, then pick Unified (a single +/- column like a patch) or Side by side (two aligned columns). Inside every changed line, the specific words that moved get a blue highlight while the untouched words stay plain, so a one-word edit in a long line is immediately visible. Stat tiles show added, removed, and modified line counts plus overall similarity, and a Merged result box contains the changed version's content along the diff, ready to copy.

Step-by-Step Usage Guide

  1. Paste the baseline document into the Original box and the edit into Changed.
  2. Pick Unified or Side by side and scan the colour-coded diff; blue spans inside lines mark the exact words that moved.
  3. Check the added, removed, modified, and similarity tiles for the shape of the change.
  4. Copy the Merged result if you want the Changed text aligned along the diff.

Technical Specifications & Standards

The tool shares the engine behind the Diff Checker (src/lib/textDiff.ts). Lines are compared with an LCS dynamic program when the middle section is small; larger sections fall back to patience-style anchoring on unique lines, and a fixed deadline guarantees the comparison either completes or degrades to coarse delete/insert blocks with an explicit warning rather than hanging the tab. Line terminators are preserved per line, so a CRLF-versus-LF input is reported in a separate line-endings banner instead of marking every line changed. Word-level intra-line highlighting tokenises the two versions of a line and runs a second LCS over the words, falling back to character level for short lines. The merged output is not a three-way merge: it simply drops deleted lines and keeps added ones, which reconstructs the Changed text.

Targeted Use Cases

  • Reviewing what actually changed between two versions of a config file, contract clause or email draft.
  • Spotting the changed word inside a long line that would otherwise read as a whole-line rewrite.
  • Comparing two exports of a list — a DNS zone, a package manifest, a user roster — to spot additions and removals.
  • Checking that a find-and-replace pass did not silently delete lines.

Notes & Gotchas

  • Keep each logical item on its own line — the comparison unit is the line, so reflowed paragraphs diff badly.
  • For very long documents, diff the changed region rather than the whole file; the engine degrades gracefully past its caps, but exact alignment is best on paste-sized documents.
  • If the banner says the only difference is line endings, the text is otherwise identical — no need to hunt further.
  • Use the merged output as a copy of the new version, not as a merge of two people's independent edits.

Frequently Asked Questions

What algorithm does the diff use?

A longest-common-subsequence engine with a cell budget, unique-line anchoring for large sections, and a hard deadline — the same family of algorithm behind diff and git, with deliberate caps so large inputs never freeze the page.

Why do some changed lines have blue highlights and others not?

Blue marks the words (or characters, on short lines) that differ when the paired lines share enough structure. Fully rewritten lines show as a plain red/green pair instead of a noisy highlight.

What is the Merged result?

It is the Changed text laid out along the diff — every kept and added line in order, deletions dropped. It is a convenience for copying the newer version, not a three-way merge of two edits.

Is my text uploaded anywhere?

No. Both inputs stay in the page's memory and the diff is computed in JavaScript on your device. Nothing is sent to any server.