DigitHelm
Everyday Use

Text Diff Checker | Compare Two Texts

Compare two blocks of text line by line and word by word. Highlights added, removed, and changed lines, shows match percentage, supports file drop, and copies JSON reports.

Instant Results100% FreeAny DeviceNo Sign-up

Match

25%

Different

Unchanged

1

lines

Added

3

insertions

Removed

3

deletions

Tokens

4↔4

lines

Similarity
25.0%
6 changes
4 lines
1
2
3
4
4 lines
1
2
3
4
Diff Output
+33
1The quick brown fox
1The quick red fox
2Jumped over the lazy dog
2Leaped over the lazy dog
3This line stays the same
3This line stays the same
4Remove this line
4Added this new line here

What Is the Text Diff Checker?

The Text Diff Checker compares two versions of text and highlights exactly what changed between them — added lines or words in green, removed content in red, and unchanged sections in white. It uses the Longest Common Subsequence (LCS) algorithm, the same approach used by Git, code review tools, and document versioning systems, to produce a minimal, precise diff rather than a naive line-by-line comparison.

Use this free online text comparison tool to review document revisions, track changes in contracts or legal documents, compare two versions of an essay or report, verify that copy edits are intentional, or check that a translated text matches the original structure. Choose between Line diff mode (comparing full lines, ideal for code and structured text) and Word diff mode (comparing individual words, ideal for prose and paragraphs where changes occur mid-sentence). Side-by-side view shows both versions in parallel columns with changed sections highlighted; Unified view shows a single stream with + and - prefixes, similar to a Git diff output.

Text Diff Checker Formula and Method

Rule 1

Longest Common Subsequence (LCS): dp[i][j] = dp[i+1][j+1] + 1 if tokens match, else max(dp[i+1][j], dp[i][j+1]).

Rule 2

Traceback produces added, removed, and unchanged token sequences.

Rule 3

Match % = (same tokens ÷ max(left token count, right token count)) × 100.

Rule 4

Word diff applies LCS on space-split words; line diff applies LCS on newline-split lines.

How to Use

  1. 1

    Paste the original (before) text into the left "Original" panel. This is the baseline — the version you are comparing against. You can paste code, prose, contract text, CSV data, or any plain text content.

  2. 2

    Paste the changed (after) text into the right "Changed" panel. This is the modified version. The diff result updates instantly as you type or paste — no submit button required.

  3. 3

    Select the diff mode. Choose "Lines" for structured text like code, lists, or documents where line boundaries are meaningful. Choose "Words" for prose paragraphs where small phrase changes within a sentence are important.

  4. 4

    Toggle Ignore Case to treat uppercase and lowercase letters as equal — useful when reviewing text that was reformatted with different capitalisation. Toggle Ignore Spaces to hide whitespace-only changes caused by reformatting or indentation changes.

  5. 5

    Switch between Side-by-side and Unified view using the view toggle. Side-by-side shows both texts in parallel columns with inline word-level highlights on changed lines. Unified view shows a single stream with + and - prefixes per token.

  6. 6

    Enable Changes Only to hide unchanged sections and see only the additions and removals — useful for large documents where most content is the same and you want to focus on what changed. Click Copy to export the unified diff as plain text.

Text Diff Checker Example

A paralegal is reviewing two versions of a service agreement — one before and one after legal review. She pastes both versions into the text diff checker and selects Line diff mode. The side-by-side view shows that three clauses were modified: liability language in section 4 was tightened (the old wording is highlighted in red, the replacement in green), a payment term was extended from 30 to 45 days, and a jurisdiction clause was added. She can see these changes at a glance rather than reading both documents in full. The Changes Only toggle collapses the unchanged sections, leaving just the three modified areas visible.

A blog editor compares two drafts of an article — the writer's original and the editor's revised version. Using Word diff mode, the tool highlights individual word-level changes within each paragraph: a passive construction replaced with active voice, "utilise" replaced with "use", and a sentence reordered for flow. The 94% match score confirms the content is substantially the same and only style edits were made.

Understanding Text Diff

How the LCS Diff Algorithm Works

The Longest Common Subsequence algorithm finds the longest sequence of tokens (words or lines) that appear in the same order in both texts, even if not consecutively. Everything in that shared sequence is marked "unchanged." Tokens in the original text that are not part of the LCS are marked "removed" (red). Tokens in the changed text that are not part of the LCS are marked "added" (green). This produces the most minimal possible diff — it identifies the fewest changes needed to transform one text into the other. The same algorithm is used by Git's diff command, Unix diff, GitHub's pull request comparison, and virtually every code review tool.

Line Diff vs Word Diff: When to Use Each

Line diff treats each newline-delimited line as a single unit. It is the right choice when line boundaries carry meaning: source code (where indentation and line structure matter), numbered lists, CSV data, configuration files, or any structured document format. A change that affects three words in a sentence will show the entire line as changed in line diff mode. Word diff splits text on whitespace and treats each word as an individual token. This produces much more granular results for prose — individual word substitutions, additions, and removals are highlighted within each line rather than the whole line being marked changed. For reviewing essays, articles, contracts, marketing copy, or any document where changes happen within sentences, word diff gives the most useful output.

Understanding the Match Percentage

The match percentage shown in the stats bar at the top is the proportion of tokens (lines or words, depending on mode) that are identical in both texts, calculated as same tokens ÷ max(left count, right count) × 100. A match of 100% means the texts are completely identical. A match of 0% means no tokens are shared. For practical document review, a match above 90% typically means minor edits; 70–90% suggests moderate revision; below 70% indicates significant rewriting. For code reviews, even a 95% match might represent a critical change if the altered lines affect program logic.

Comparing Text Files, Code, and Documents

This online text difference tool handles any plain text content you can paste into a text field. For code comparison, line diff mode with Ignore Whitespace enabled focuses on logical changes while hiding pure indentation differences. For contract or legal document review, line diff mode shows added and removed clauses clearly. For SEO content audits, word diff mode in a long article quickly surfaces substituted keywords or rewritten passages. For translation review, comparing source and translated text in word diff mode highlights structural differences in sentence length and word choice. The tool works equally well for English and most Unicode text including accented Latin characters.

Privacy and Security of Your Text

All diffing is performed entirely in your browser using JavaScript. No text you paste into either panel is sent to any server or stored anywhere. The tool has no backend, no database, and no logging. Both text panels are cleared when you leave the page. This makes the tool safe for reviewing confidential documents, proprietary code, legal agreements, and any text you would not want transmitted over the internet.

Frequently Asked Questions

What is the difference between line diff and word diff?

Line diff compares the two texts line by line — the unit of comparison is a full line delimited by a newline character. A change that affects even one word in a line marks the entire line as changed. Line diff is best for code, config files, CSV data, and structured documents where line boundaries are meaningful. Word diff splits the text on whitespace and compares individual words. A change that substitutes one word shows only that word highlighted, leaving the rest of the sentence marked unchanged. Word diff is best for prose writing — articles, contracts, essays — where changes happen within sentences and you want word-level precision.

Can I compare more than two files?

This tool compares exactly two text inputs at a time — one "before" and one "after." It is designed as a two-way diff tool, which matches the most common use case: comparing a previous version with a current version. For three-way merging (comparing two derived versions against a common ancestor, as used in complex Git merges), a dedicated version control system or a tool like KDiff3 is more appropriate. For comparing many versions in sequence, do multiple two-way comparisons — paste version 1 vs version 2, review the diff, then paste version 2 vs version 3.

What does the "Ignore Whitespace" option do?

The Ignore Whitespace option normalises all whitespace in both texts before comparing them — multiple spaces are collapsed to one, and leading and trailing spaces are trimmed from each token. This means a line that was reformatted (indentation changed, extra spaces added) will not show as a change if its non-whitespace content is identical. This is particularly useful for comparing code where someone ran a formatter or changed indentation style without changing logic. It is also useful for comparing text that was copied from different sources where extra spaces may have been introduced during copy-paste.

What does the match percentage mean?

Match percentage = (number of identical tokens) ÷ max(left token count, right token count) × 100. It measures how similar the two texts are based on shared content, not position. A 95% match means 5% of the larger text's tokens are changed; a 50% match means half the content is different. The percentage is computed after applying any active options (Ignore Case, Ignore Whitespace), so it reflects your filtered comparison. Colour coding makes the match easy to read at a glance: green indicates 80% or above (highly similar), amber is 50–79% (moderate changes), red is below 50% (significantly different).

Can I use this tool to compare code files?

Yes — line diff mode is particularly effective for code comparison. Paste two versions of a function, a configuration file, or any code snippet and the tool highlights added and removed lines exactly as Git diff would. Enable Ignore Whitespace if the code was reformatted (indentation changed, spaces around operators adjusted) to focus only on meaningful logic changes. Changes Only mode collapses unchanged sections, showing only the modified lines — ideal for reviewing a long file with a small change. The monospaced font in the diff output correctly renders code indentation and alignment.

Is my text kept private?

Yes. The diff algorithm runs entirely in your browser in JavaScript — no text is sent to any server. Both panels are plain HTML textarea elements, and their content never leaves your device. When you close or navigate away from the page, the text is gone. This means the tool is safe to use with confidential documents, proprietary source code, legal agreements, and personal writing. There is no login, no history, and no server-side processing of any kind.