Text Diff Checker Online — How to Compare Two Texts, Code & Files Free

Everything you need to know about comparing two texts online — diff modes, view options, similarity scoring, unified patch format, ignore options, and real-world use cases for developers, writers, SEO teams, and data analysts. All examples link directly to the tool.

Published April 26, 2026 · 11 min read
Skip straight to the tool — compare two texts in seconds
Line · Word · Character · Split · Inline · Patch · No signup · Nothing uploaded
Open Text Diff Checker →

What Is a Text Diff — and How Does It Work?

A diff (short for difference) is an operation that compares two texts and produces a description of what changed between them — which content was added, which was removed, and which stayed the same.

The ToolLance diff checker uses the LCS (Longest Common Subsequence) algorithm — the same algorithm that powers git diff, GitHub pull request diffs, and most version control systems. LCS finds the longest sequence of tokens (lines, words, or characters) that appear in both texts in the same order, then identifies everything that falls outside that sequence as a change.

This produces the minimal diff — the smallest set of additions and deletions that transforms text A into text B. That minimality matters: it means the diff focuses on what actually changed, not on arbitrary alignment choices.

How LCS diff works — simple example
Text AThe quick brown fox
Text BThe slow brown dog
LCS found"The" + "brown"
Deleted (A only)"quick" + "fox"
Inserted (B only)"slow" + "dog"
ResultThe [~~quick~~] [slow] brown [~~fox~~] [dog]

How to Compare Two Texts Online (Step-by-Step)

Step-by-step — compare two texts
1
Paste your original text into pane A
Go to toollance.com/tools/text-diff-checker. Paste the before version into the left pane (Original A), or click Open to upload a text file.
2
Paste your modified text into pane B
Paste the after version into the right pane (Modified B). The word count, line count, and character count update live as you type.
3
Choose your diff mode and view
Select Line, Word, or Character under Compare by. Select Split, Inline, or Unified under View. Enable Ignore Case or Ignore Whitespace if relevant.
4
Read the diff and check the stats
Green highlights show additions in B, red shows deletions from A. The stats strip shows similarity %, lines added/removed, words added/removed, and chars added/removed.
5
Download or copy
Click .patch to download a unified diff file, or Download to save the changes as plain text. Copy button copies the result to clipboard.

Diff Modes — Line, Word, and Character: Which to Use

Choosing the right diff granularity determines how useful the result is. Too coarse and you miss important changes; too fine and the diff is noisy and hard to read.

ModeGranularityBest forPro tip
Line diffOne line at a timeCode, config files, CSV, log files, JSONUse with Ignore whitespace to skip indentation-only changes in reformatted code.
Word diffOne word / whitespace token at a timeDocuments, articles, essays, legal text, blog postsThe default choice for document comparison — it shows exactly which words changed without hiding context.
Character diffOne character at a timeTypo detection, serial numbers, version strings, passwords, precise editsUse when the texts are similar and you need to find very small differences like a single transposed letter.

View Modes — Split, Inline, and Unified Patch

Split (side-by-side)

Original on the left, modified on the right. Changes highlighted in each panel. The standard view for comparing two versions.

Best for: General comparison — the most intuitive layout when you want to read both versions simultaneously.

Inline

Both additions and deletions appear in a single stream. Additions are green, deletions are red with strikethrough. More compact than split view.

Best for: Quick visual scanning when you want to see the full text with changes marked, without scrolling two panes.

Unified patch

Standard unified diff format (git diff output). Lines with + are additions, - are deletions, space-prefixed lines are context. Compatible with git apply and the Unix patch command.

Best for: Developers who need a patch file, code reviewers, and anyone integrating with version control workflows.

Unified Diff Format — What It Is and How to Use It

The unified diff format (also called patch format) is the standard output of git diff, diff -u, and every major code review tool. It encodes exactly what changed between two files in a compact, machine-readable text format:

--- original
+++ modified
@@ hunk @@
 The quick brown fox
-jumps over the lazy dog.
+leaps over the lazy cat.
 This is unchanged context.

Lines starting with - were in the original (A) but not the modified (B). Lines starting with + are in B but not A. Lines starting with a space are unchanged context — they appear in both versions and provide surrounding reference.

To apply a downloaded patch file using Git: git apply output.patch. To apply using the Unix patch command: patch -p0 < output.patch.

Ignore Options — Case, Whitespace, and Blank Lines

Real-world texts often differ in ways that are not semantically meaningful — capitalization conventions, indentation style, blank lines between sections. The three ignore options let you filter these out so the diff focuses on the content that actually matters.

OptionWhat it doesExampleUse when
Ignore caseLowercases both texts before comparing'Hello' and 'hello' → treated as identicalHTML attributes, SQL identifiers, configuration keys, case-normalized data imports
Ignore whitespaceTrims lines and collapses internal spaces in line mode; skips whitespace tokens in word mode' hello world ' and 'hello world' → treated as identicalComparing reformatted code, YAML re-indented configs, editors that auto-format on save
Ignore blank linesFilters out empty or whitespace-only lines before comparingTwo blank lines between paragraphs vs one → not flagged as a differenceComparing minified vs formatted code, data exports with variable blank line conventions

Similarity Score — What the Percentage Means

The similarity score is calculated as:

Similarity = (unchanged characters) ÷ (total characters) × 100%
  • 100% — the texts are identical
  • 80–99% — minor edits (typical for version updates, typo fixes)
  • 50–79% — significant changes but shared structure (section rewrites)
  • 20–49% — heavily rewritten content with some shared phrases
  • 0–19% — largely different content

The similarity percentage is always character-level, regardless of which diff mode (line/word/char) is selected. It gives a quick summary of how much the texts share in common before you read the detailed diff.

How to Compare Code Files Online

Step-by-step — compare code files
1
Upload or paste your source files
Click Open next to pane A to upload the original file. Click Open next to pane B to upload the modified version. Supported: .js, .ts, .css, .html, .json, .yaml, .md, .csv, .log, .xml, .txt.
2
Select Line diff mode
Click Line under Compare by. This shows which entire lines were added or removed — the standard code review view. Individual word-level highlighting within lines is not available in line mode.
3
Enable Ignore whitespace if reformatted
If the code was auto-formatted, re-indented, or had trailing spaces cleaned up, enable Ignore whitespace. This shows only the meaningful logical changes.
4
Download as .patch for version control
Click .patch to download a unified diff file. Apply it with: git apply output.patch, or share it with teammates for review.

Supported File Formats and Recommended Settings

FormatTypeRecommended modeNotes
.txtPlain textWord or LineGeneral-purpose text files
.mdMarkdownWord or LineDocumentation, README files
.jsonJSONLineFormat both inputs first with consistent indentation
.js / .tsJavaScript / TypeScriptLineEnable Ignore whitespace for reformatted code
.cssCSS / SCSSLineEnable Ignore whitespace for minified vs formatted
.htmlHTMLLineUse Line for structure, Word for content
.yaml / .ymlYAMLLineEnable Ignore whitespace for indentation changes
.csvCSVLineSort rows before comparing to avoid false positives
.logLog filesLineIgnore blank lines option useful for sparse logs
.xmlXMLLineFormat both inputs consistently before comparing

Who Uses a Text Diff Tool — Real-World Use Cases

WhoTaskSettingsTip
Frontend / backend developersCompare two versions of a source file before and after refactoringLine diff · Split or UnifiedEnable Ignore whitespace if only indentation changed. Download .patch to share with teammates.
Technical writers and editorsSee exactly which words changed between document draftsWord diff · Split or InlineWord diff shows sentence-level changes more clearly than line diff for prose.
SEO and content teamsCompare page content before and after a rewriteWord diff · InlineSimilarity % tells you how much of the original content was kept — useful for understanding content freshness.
DevOps and system administratorsCompare config files or YAML manifests between environmentsLine diff · SplitEnable Ignore whitespace for YAML files where indentation may differ. Enable Ignore blank lines for ini files.
Data analystsCompare CSV exports from two time periods to find new or removed rowsLine diff · SplitSort your CSV before pasting to avoid false diffs from row reordering.
Students and academicsTrack edits between essay drafts, compare sources, check for unintended changesWord diff · SplitThe similarity score gives a quick sense of how much was rewritten between drafts.
Legal and compliance teamsCompare contract versions to find clause changesWord diff · InlineEnable Ignore case if capitalization conventions changed between versions.
API developersCompare JSON responses from two API versionsLine diff · Split or UnifiedFormat both JSON blobs with consistent indentation using the JSON Formatter before pasting for the cleanest diff.

How to Compare JSON Files Online

JSON comparison is one of the most common developer use cases for a diff tool — comparing API responses between versions, checking config file changes, or verifying that a data transformation produced the expected output.

The critical step before diffing JSON: format both inputs with consistent indentation. If one JSON blob uses 2-space indentation and the other uses 4-space (or was minified), almost every line will show as a difference even if the data is identical. Use the JSON Formatter to normalize both inputs to 2-space indentation first, then paste them into the diff checker.

Then use Line diff mode and Split view. Each changed property or value will show as a removed line (red) and an added line (green). The similarity score will reflect how much of the JSON structure is unchanged.

Privacy — Your Text Never Leaves Your Browser

All text comparison runs locally in your browser using JavaScript. No text, no files, and no diff results are sent to any server. This is especially important for:

  • Source code — proprietary algorithms, unreleased features, internal APIs
  • Legal documents — contracts, NDAs, employment agreements
  • Medical or financial records — any document with personally identifiable information
  • API responses — which may contain user data or authentication tokens
  • Configuration files — which may contain credentials, secrets, or environment variables

You can verify this by opening your browser Network tab and confirming no outbound requests are made when you paste text and run the diff.

Related Tools

Comparing JSON files? Format both inputs with consistent indentation first using the JSON Formatter & Validator — it also catches syntax errors before you try to diff. Comparing CSS or JavaScript files and need to minify the result after reviewing? The CSS & JS Minifier handles that in one step. Comparing PDF documents rather than plain text? PDF Diff Tool extracts the text from both PDFs and runs a word-level comparison.

Frequently Asked Questions

What is a text diff checker?

A text diff checker compares two texts and shows exactly what changed — what was added, what was removed, and what stayed the same. This tool uses the LCS (Longest Common Subsequence) algorithm, the same algorithm used by git diff, to find the minimal set of changes.

What is the difference between line, word, and character diff?

Line diff compares entire lines — best for code and structured text. Word diff compares individual words — best for documents and prose. Character diff compares every character — best for finding exact typos and single-character changes.

What is unified diff / patch format?

Unified diff is the standard format used by git diff and code review tools. Lines with + are additions, lines with - are deletions, lines with a space are unchanged context. Download as .patch and apply with git apply output.patch or patch -p0 < output.patch.

Can I compare JSON or code files?

Yes. Upload any text-based file (.js, .ts, .css, .html, .json, .yaml, .csv, .log) or paste directly. Use Line diff for code. For JSON, format both inputs with consistent indentation using the JSON Formatter first. Enable Ignore whitespace for reformatted code.

What does the similarity percentage mean?

Similarity = (unchanged characters) ÷ (total characters) × 100%. 100% means identical. It reflects character-level similarity regardless of which diff mode is selected.

Is my text uploaded to a server?

No. All comparison runs entirely in your browser. Nothing is sent to any server — safe for private code, contracts, medical records, and any sensitive content.

What does Ignore whitespace do?

In line mode, it trims leading/trailing spaces and collapses internal spaces before comparing. A line with different indentation is treated as identical if the content matches. Use it when comparing reformatted or re-indented code.

How do I apply a downloaded .patch file?

With Git: git apply output.patch. With the Unix patch command: patch -p0 < output.patch. The patch applies the additions and deletions shown in the diff to the target file.

Can I compare document versions or track edits?

Yes. Paste the original version in pane A and the edited version in pane B. Use Word diff mode for documents. The diff highlights every word that was added or removed, with statistics showing how many words changed.

What does Ignore case do?

It lowercases both texts before comparing, so "Hello" and "hello" are treated as identical. Use when comparing HTML attributes, SQL identifiers, or any text where capitalization differences are not meaningful.