ToolActToolAct

Text Comparison Tool

Original TextOLD
1
New TextNEW
1
0 lines added0 lines removed
UTF-8

What is Text Diff?

Text Diff compares two versions of text and highlights which lines or sections were added, removed, changed, or left unchanged. Reviewers use it for code snippets, configuration files, translations, contract drafts, Markdown documents, prompt versions, release notes, and log excerpts without manually scanning both copies side by side. The tool is especially valuable when a small edit is hidden inside a long file or when formatting, whitespace, punctuation, or ordering may have changed unexpectedly. A diff does not decide whether the new version is correct; it simply shows exactly where the text differs so the real review can be focused and less error-prone.

How to Use

How to use

  1. Paste original text in the left input box
  2. Paste modified text in the right input box
  3. The system automatically calculates and highlights differences, and the status bar shows added and removed line counts

Review Tips

  • Normalize line endings and whitespace before comparing when the real change is content rather than formatting.
  • For code or legal text, review highlighted changes manually; automatic diffing shows differences but does not judge intent or correctness.

Use Cases

Compare two text versions line by linePaste original and modified text into side-by-side editors and the tool computes a line diff using a dynamic-programming edit-distance approach. Added lines are highlighted on the right and removed lines on the left. The status line reports counts of added and removed lines so reviewers can see the magnitude of change at a glance.
Review small edits without a full Git workflowThe old and new panels include line numbers, clear and paste actions, and status counts for lines added and removed. It is useful for comparing translations, config snippets, generated text, or copied notes outside a repository. Quick diffs in the browser keep reviewers focused on content rather than commit history.
Spot structural changes quicklyBecause the comparison works at the line level, it emphasizes inserted and deleted lines rather than character-level typos. That makes it best for paragraphs, lists, JSON fragments, documentation sections, and multi-line outputs. For character-level proofing, pair the result with a separate character-level diff or a spell checker.
Review prompt and config changes before mergingPaste the previous prompt and the new one into the two panels to see exactly which lines were added, removed, or reordered. That is faster than re-reading the full text when only a temperature, system message, or instruction block changed between versions. The line-level view catches accidental section moves that a word-count comparison would miss.
Audit diffs produced by the Myers algorithm and LCSUnder the hood, the diff engine runs the Myers O(ND) algorithm on the Longest Common Subsequence to produce an edit script, then applies semantic cleanup so word-boundary shifts (e.g., a sentence broken across two lines) collapse to a single changed line rather than two adjacent red/green blocks. The result still reads as a normal line diff, but the LCS basis means the smallest possible set of edits is what shows up in the side-by-side view.

Technical Principle

Line-level diffing is built on the Longest Common Subsequence (LCS) problem: given two sequences of lines A and B, find the longest sequence that appears in both in the same relative order. Everything not in the LCS is either an insertion (present in B but not in A) or a deletion (present in A but not in B), which is exactly the set of red and green rows the side-by-side view displays. The naive LCS dynamic-programming table runs in O(M * N) time and space, where M and N are the line counts of the two inputs. In practice the diff engine uses the Myers diff algorithm (Eugene Myers, 1986), which solves the same problem in O((M + N) * D) time, where D is the edit distance between the two files. For two files that are mostly identical, D is small and Myers is dramatically faster than the full DP table; Git's default diff backend, GitHub's web diff view, and most IDE diff panels all use Myers or one of its descendants (patience diff, histogram diff) for exactly this reason. Patience diff additionally aligns on uniquely-occurring lines first, which produces more readable hunks when blocks of code have been moved around. The output is a sequence of equal/insert/delete operations rendered as a unified diff in CLI tools (with @@ -m,n +p,q @@ hunk headers and a single +/- prefix per line) or as side-by-side colored rows in a web UI. Character-level or word-level diffs use the same algorithm on a finer-grained sequence, often paired with the Levenshtein distance (insertion + deletion + substitution costs) when substitutions need to be counted as a single operation. The diff-match-patch library by Neil Fraser is the common reference implementation for web-based character-level diffs.

  • LCS basis: the Longest Common Subsequence of the two line arrays defines the unchanged rows; everything else is an insert or delete
  • Myers diff (1986): O((M + N) * D) time where D is edit distance; default backend in Git, GitHub, and most IDE diff views
  • Naive DP: O(M * N) time and space — fine for small inputs but quadratic memory makes it impractical for large files
  • Patience diff: aligns on uniquely-occurring lines first; produces cleaner hunks for moved or reordered blocks
  • Output formats: unified diff with @@ -m,n +p,q @@ hunk headers for CLI; side-by-side colored rows for web UI
  • Granularity: line / word / character diffs apply the same algorithm to a different segmentation of the input
  • Levenshtein distance: counts insertions + deletions + substitutions; diff-match-patch is the reference web library

Examples

Spot a one-word change inside a paragraph

Original:
  The server starts on port 3000 by default.

Modified:
  The server starts on port 8080 by default.

Result: 1 line changed (3000 -> 8080)

Compare two versions of a config block

Original:                       Modified:
  timeout: 30                     timeout: 60
  retries: 3                      retries: 3
  debug: false                    debug: true
                                  log_level: info

Result: 2 lines added, 2 lines removed

Diff before-and-after release notes

Removed (red):
  - Fixed login redirect on Safari 16

Added (green):
  - Fixed login redirect on Safari 16 and 17
  - Added dark mode preference sync

Result: 2 lines added, 1 line removed

Detect reordered JSON keys

Original:                       Modified:
  { "name": "alice",              { "id": 1,
    "id": 1,                        "name": "alice",
    "role": "admin" }               "role": "admin" }

Result: 2 lines changed (key order differs, values identical)

FAQ

What kind of diff does it show?

Line-level diff. The page shows two side-by-side panels: removed lines highlighted in red on the left, added lines highlighted in green on the right. Line numbers help locate changes. The status bar shows the count of added and removed lines.

Which diff algorithm is used?

The page uses a Longest Common Subsequence (LCS) algorithm to compute the edit script at the line level. For typical document sizes this runs in real time as you type. The algorithm finds the shortest sequence of insertions and deletions to transform the left text into the right text.

Why does the diff look different from git diff?

Git uses its own diff implementation with configurable algorithms. This page uses a JavaScript LCS-based diff that runs entirely in the browser. The output format and hunk boundaries may differ slightly from git diff, but the underlying edit detection is correct for line-level text comparison.

Can I diff just within a paragraph or sentence?

Yes - paste each version into a side. The page also offers character-level highlight inside changed lines, which is what makes 'rename foo to bar' show as inline replacement instead of two unrelated changes.

Does it ignore whitespace?

No. The diff is whitespace-sensitive by default. Whitespace differences (trailing spaces, extra blank lines, different line endings) are shown as changes.

Can I diff JSON or XML structurally?

Pure text diff is line-based. To diff JSON by key (key 'a' moved from position 1 to 3 with same value = no change), use a JSON-aware diff tool (jsondiffpatch, json-diff). This page is for textual comparison.

Is my text uploaded?

No. Diff runs in your browser. Both inputs are processed locally and not transmitted.