Skip to main content

Free Text Diff

Compare two blocks of text and see exactly what changed. Line-by-line diff with added, removed, and unchanged lines.

Works offline once loaded
Context:
+3 addedβˆ’2 removed2 unchanged
Diff
+The quick brown fox leaps over the lazy dog.
βˆ’The quick brown fox jumps over the lazy dog.
Pack my box with five dozen liquor jugs.
+How amazingly quick daft zebras jump!
βˆ’How vexingly quick daft zebras jump!
The five boxing wizards jump quickly.
+Now is the time for all good men.

Common uses

  • Compare Code SnippetsSpot exactly what changed between two versions of a code snippet, config, or script.
  • Compare Document DraftsFind every change between two drafts of a document, contract, or article β€” line by line.
  • Compare Data and CSV FilesSpot differences between two versions of exported data, CSVs, logs, or configuration.
  • Compare Translation VersionsSee what changed between two versions of a translated document, subtitle file, or localisation string.
  • Track Changes in Content RevisionsCompare original and edited versions of an article, blog post, or marketing copy to review what changed.

How It Works

Text Diff uses a hand-written Longest Common Subsequence (LCS) algorithm implemented directly in this tool β€” no external diff library. Everything runs in the browser; your text is never sent to a server.

  1. 1
    Text is split into lines
    Each textarea's content is split on newline characters into an array of lines. Optional normalisation (lowercasing, collapsing whitespace) is applied to a copy of those arrays before comparison, while the originals are kept for display.
  2. 2
    LCS table computed in a Uint32Array
    A bottom-up dynamic-programming table is built in a typed Uint32Array β€” O(mΓ—n) in both time and memory. For inputs whose combined cell count would exceed 4 million (about 16 MB), the algorithm falls back to a coarser block diff automatically so the page stays responsive.
  3. 3
    Word-level highlights on changed lines
    When a deleted line is immediately followed by an inserted line, a second LCS pass runs on the tokenised words of that pair (split on whitespace). This produces inline highlighted segments showing exactly which words changed within the line, not just which lines changed.
  4. 4
    Unified-diff view with context collapsing
    The ops list is rendered as a unified diff with +/βˆ’ prefixes and colour coding. Unchanged lines outside the configurable context window (default: 3 lines) are collapsed behind an ellipsis. The full result can be copied to the clipboard or downloaded as a plain-text .txt file.

Related Tools

Frequently Asked Questions