Text Diff & Comparison Tool

Compare two text documents, code files, or configuration snippets to instantly visualize additions, deletions, and modifications. Supports side-by-side split view, inline unified diffs, character-level diff highlighting, and Git-compatible patch export.

How to use

1

Paste or type your original text into the left (Original) panel.

2

Paste or type your modified text into the right (Modified) panel.

3

Toggle comparison options: Side-by-Side (Split) or Inline (Unified) view, case sensitivity, and whitespace ignoring.

4

Inspect additions highlighted in green and deletions highlighted in red with sub-line character precision.

5

Copy or download the generated standard unified diff patch (.patch) file for use in Git or command-line patch tools.

How text difference comparison works

Text difference comparison algorithms analyze two input sequences (typically lines of text) to determine the minimum number of insertions and deletions required to transform the original sequence into the modified sequence. This computational problem is known as the Shortest Edit Script (SES) problem, which is dual to finding the Longest Common Subsequence (LCS).

The Myers diff algorithm

Standardized by Eugene W. Myers in 1986 (An O(ND) Difference Algorithm and Its Variations), the Myers algorithm forms the operational foundation of distributed version control tools including Git, Mercurial, and GNU diff. The algorithm models string comparison as a graph search through an edit graph of size $(N + 1) \times (M + 1)$, where diagonal moves represent identical lines, horizontal moves represent deletions, and vertical moves represent insertions. By executing a breadth-first search along diagonal $k$-lines, the algorithm discovers the minimal edit path in $O(ND)$ time and space, where $D$ is the total count of differences.

Diff view modes: Side-by-Side vs Unified

ModeLayoutBest Use Case
Side-by-Side (Split)Two parallel columns with aligned lines.Visual code reviews, inspecting structural reformatting, and comparing long lines.
Unified (Inline)Single sequential column with + and - prefix markers.Generating standard Git patches, reviewing compact changes, and terminal printing.

Character-level intra-line difference highlighting

When an entire line is modified, viewing the whole line as deleted and replaced makes small typographical or variable changes difficult to identify. Our comparison engine performs two-tier diffing: first identifying matching lines via LCS, and subsequently performing sub-line word and character diffing across paired modifications to highlight the exact modified words or characters.

Zero server transmission guarantee

Source code files, legal contracts, configuration credentials, and private documents are processed strictly inside your local web browser using client-side JavaScript. No text snippets or diff outputs are transmitted across external networks.

Frequently asked questions

What diff algorithm is used by this comparison tool?

This tool implements a Longest Common Subsequence (LCS) and Myers diff algorithm in pure client-side JavaScript, matching the core difference logic used by GNU diff and Git.

Can I export the comparison as a Git patch file?

Yes. Switch to the Unified Diff view or click 'Copy Patch' to copy standard unified diff format strings compatible with the unix patch utility and Git commit review tools.

How does the tool handle whitespace differences and line breaks?

You can toggle 'Ignore Whitespace' to disregard leading, trailing, and repeated whitespace differences, as well as normalize Windows (CRLF) and Unix (LF) line terminators.

What is the similarity score percentage?

The similarity score is calculated as (2 * common_length) / (len_original + len_modified) * 100, indicating the mathematical proportion of matching content between the two inputs.

Is my text uploaded or stored on any server?

No. All text parsing, diff calculation, and rendering execute entirely inside your local web browser session. No data is stored, cached, or sent to external servers.