Compare Text
This text diff tool compares two blocks of text side by side and highlights every difference. Added lines are green, removed lines are red, and changed lines are yellow with word-level highlighting. Everything runs in your browser — nothing is sent to any server.
How to Use This Text Diff Tool
- Paste the original text into the "Original (Text A)" field on the left.
- Paste the modified text into the "Modified (Text B)" field on the right.
- View the diff instantly — differences are highlighted as you type.
The diff updates in real time. Added lines (present only in Text B) appear in green. Removed lines (present only in Text A) appear in red. Changed lines (present in both but different) appear in yellow with the specific changed words highlighted.
Use the Swap button to switch Text A and Text B. Use Copy Unified Diff to get the output in standard unified diff format (the same format used by git diff).
Examples
Example 1: Spotting a Typo Fix
Result: The line is marked as changed. Word-level diff highlights "lasy" → "lazy" so you see exactly what was corrected.
Example 2: Comparing Configuration Files
port=8080 debug=true max_connections=100
port=8080 debug=false max_connections=200 log_level=info
Result: "port=8080" is unchanged. "debug" and "max_connections" lines show as changed with the specific values highlighted. "log_level=info" is marked as added.
Example 3: Reviewing Prose Edits
We are happy to inform you that your application has been received. We will review it shortly. Thank you for your patience.
We are pleased to inform you that your application has been received. Our team will review it within 48 hours. Thank you for your patience.
Result: Line 1 shows "happy" → "pleased" as a word-level change. Line 3 shows the full revision. Lines 2 and 4 are unchanged.
How Text Diffing Works
A text diff (short for "difference") is an algorithm that compares two texts and identifies what changed between them. Here is what happens behind the scenes:
- Split into lines: Both texts are split into arrays of lines using newline characters as separators.
- Find the Longest Common Subsequence (LCS): The algorithm identifies the longest sequence of lines that appear in both texts in the same order. These are the "unchanged" lines — the backbone of the comparison.
- Mark differences: Lines not in the LCS are classified as additions (new in Text B), removals (missing from Text B), or changes (same position, different content).
- Word-level diff (optional): For changed lines, a second pass compares individual words within each line to show exactly which words were added, removed, or modified.
This tool uses a simplified line-by-line comparison with word-level highlighting for changed lines. Professional diff tools like git diff use more sophisticated algorithms (Myers' diff, patience diff) that handle insertions and deletions across different line positions — producing more compact and readable output for large files.
Common Use Cases
- Code review: Compare two versions of source code to see what changed between commits or branches.
- Configuration auditing: Compare server configs,
.envfiles, or infrastructure-as-code templates before and after changes. - Document proofreading: Compare drafts of articles, contracts, or emails to track editorial changes.
- Data validation: Compare CSV exports, SQL query results, or API responses between environments (staging vs. production).
- Copy-paste verification: Confirm that copied text matches the original — catch invisible characters, trailing spaces, or encoding issues.
- Translation review: Compare original and translated texts side by side to verify nothing was accidentally omitted.
- Merge conflict resolution: Compare conflicting versions of a file to decide which changes to keep.
- Debugging: Compare expected output vs. actual output in test results to pinpoint failures.
Diff Formats Explained
There are several standard formats for representing text differences. Here are the most common:
Side-by-Side Diff
Shows the original text in a left column and the modified text in a right column, with changes highlighted by color or markers. This is the format used by this tool. It is the most visual and easiest to read for shorter texts.
Unified Diff
Shows changes in a single column. Lines starting with - are removals, lines starting with + are additions,
and unmarked lines are unchanged context. This is the default output of git diff and diff -u.
@@ -1,3 +1,4 @@ port=8080 -debug=true -max_connections=100 +debug=false +max_connections=200 +log_level=info
Context Diff
An older format that shows changes with surrounding context lines. Uses *** and --- markers to separate the original and modified sections. Largely replaced by unified diff in modern tools.
| Format | Best For | Used By |
|---|---|---|
| Side-by-side | Visual review, small changes | IDEs, web diff tools, Meld |
| Unified diff | Code review, patches, sharing | git diff, GitHub, patch command |
| Context diff | Legacy systems | diff -c, older patch workflows |
| Word diff | Prose, documentation changes | git diff --word-diff, wdiff |
Common Mistakes
- Ignoring whitespace differences: Trailing spaces, tabs vs. spaces, and different line endings (LF vs. CRLF) are invisible but cause diffs. These are especially problematic in YAML, Python, and Makefiles where whitespace is syntactically significant.
- Comparing formatted vs. unformatted text: If you reformat JSON, XML, or code (e.g., run a formatter), every line may show as changed even though the content is identical. Normalize formatting before comparing when possible.
- Pasting from rich text editors: Copying from Word, Google Docs, or email clients can introduce hidden formatting characters, smart quotes (" vs "), and non-breaking spaces that cause unexpected diffs.
- Line ending differences: Windows uses CRLF (
\r\n) while macOS/Linux use LF (\n). These invisible differences can make every line appear changed. - Encoding mismatches: Comparing UTF-8 text with Latin-1 or other encodings can produce false differences for any non-ASCII characters (accents, symbols, emoji).
- Comparing unrelated versions: A diff between two completely different texts is not useful — it shows everything as changed. Diffs are most valuable when the texts share a common origin.
Frequently Asked Questions
What is a text diff?
A text diff (short for "difference") compares two blocks of text and highlights what changed between them. Lines that were added, removed, or modified are marked separately so you can see exactly what is different. Diff tools are widely used in programming, writing, and document review.
How does a line-by-line diff work?
A line-by-line diff splits both texts into lines, then compares them position by position. Lines that match are marked as unchanged. Lines present only in the second text are marked as added. Lines present only in the first text are marked as removed. Lines at the same position but with different content are marked as changed.
What is the difference between a line diff and a word diff?
A line diff compares entire lines — if any character on a line changes, the whole line is flagged. A word diff goes further by highlighting exactly which words within a changed line are different. Word-level diffs are more useful when lines have only small edits, like fixing a typo or changing a single value.
What is a unified diff format?
Unified diff is a standard text format that shows changes in a single column. Lines starting with + are additions,
lines starting with - are removals, and lines with no prefix are unchanged context. It is the default format used by
git diff and most version control systems. Use the "Copy Unified Diff" button in this tool to get output in this format.
Can I compare code with this tool?
Yes. This tool compares any plain text, including source code in any language, configuration files, JSON, XML, CSV, SQL, Markdown, and more. It compares text character-by-character within each line, so it works with any format.
What are common uses for a text diff tool?
Common uses include comparing code revisions, reviewing document edits, auditing configuration changes, verifying data migrations, comparing API responses across environments, proofreading, and validating that copy-pasted text matches the original.
Is my text sent to a server?
No. This text diff tool runs entirely in your browser using JavaScript. Your text never leaves your device. Nothing is stored, transmitted, or logged. You can verify this by using the tool offline after the page loads.
What is the difference between diff and merge?
Diff identifies the differences between two texts. Merge combines changes from two texts into one result, resolving conflicts where both versions changed the same section. Diff is a read-only comparison; merge is an action that produces new output.
How do I read a diff output?
In a side-by-side diff, the left column shows the original text and the right column shows the modified text. Green highlighted lines are additions (new in Text B). Red highlighted lines are removals (only in Text A). Yellow highlighted lines are modifications (different content at the same line position).
Can this tool handle large texts?
This tool handles texts of several thousand lines comfortably in most browsers. For very large files (10,000+ lines), performance depends on your device. Since everything runs client-side, there is no server-side size limit, but very large diffs may be slow to render.
Why do whitespace differences matter?
Whitespace differences — spaces, tabs, trailing spaces, different line endings — are invisible to the eye but can cause real issues. In Python, YAML, and Makefiles, whitespace is syntactically significant. In version control, whitespace changes can clutter diffs and make real changes harder to spot.
What is the LCS algorithm used in diff tools?
LCS stands for Longest Common Subsequence. It is the core algorithm behind most diff tools. By finding the longest sequence of lines that appear in both texts in the same order, the algorithm identifies the minimal set of additions and removals needed to transform one text into the other — producing clean, readable diffs.
Related Tools
- JSON Diff Viewer — compare two JSON documents with structural awareness
- JSON Formatter — format and validate JSON before comparing
- Duplicate Line Remover — remove duplicate lines from text
- Whitespace Cleaner — clean up trailing spaces, tabs, and line endings
- Character & Word Counter — count characters, words, and lines in text
Privacy & Limitations
- Client-side only. No data is sent to any server. No cookies, no tracking. All comparisons run in your browser using JavaScript.
- Line-by-line comparison. This tool compares texts line by line at each position. It does not use LCS-based insertion detection — a line inserted in the middle will cause all subsequent lines to appear as changed. For code review with insertion awareness, use
git diffor a dedicated diff editor. - Plain text only. Rich text formatting (bold, italic, links) from Word or Google Docs is stripped when pasted. Only the text content is compared.
- Browser performance. Texts over 10,000 lines may be slow to diff on older devices. There is no hard limit.
Related Tools
View all toolsAnagram Checker
Check if two words or phrases are anagrams
Word Counter
Count words, characters, and sentences
Keyword Density Calculator
Analyze keyword frequency and density for SEO
Text Case Converter
Convert text to upper, lower, title, or sentence case
Slug Generator
Turn text into a clean URL slug
Reading Time Estimator
Estimate reading time from word count
Text Diff Tool FAQ
What is a text diff?
A text diff (short for 'difference') compares two blocks of text and highlights what changed between them. Lines that were added, removed, or modified are marked separately so you can see exactly what is different. Diff tools are widely used in programming, writing, and document review.
How does a line-by-line diff work?
A line-by-line diff splits both texts into lines, then compares them position by position. Lines that match are marked as unchanged. Lines present only in the second text are marked as added. Lines present only in the first text are marked as removed. Lines that exist in both positions but differ in content are marked as changed.
What is the difference between a line diff and a word diff?
A line diff compares entire lines — if any character on a line changes, the whole line is flagged. A word diff (or inline diff) goes further by highlighting exactly which words within a changed line are different. Word-level diffs are more useful when lines have only small edits.
What is a unified diff format?
Unified diff is a standard format that shows changes in a single column. Lines starting with + are additions, lines starting with - are removals, and lines with no prefix are unchanged context. It is the default format used by git diff and most version control systems.
Can I compare code with this tool?
Yes. This tool compares any plain text, including source code, configuration files, JSON, XML, CSV, SQL, and more. It compares text character-by-character within each line, so it works with any programming language or data format.
What are common uses for a text diff tool?
Common uses include comparing code revisions, reviewing document edits, checking configuration file changes, verifying data migrations, comparing API responses, proofreading text changes, and validating copy-paste accuracy. Any situation where you need to know what changed between two versions of text.
Is my text sent to a server?
No. This text diff tool runs entirely in your browser using JavaScript. Your text never leaves your device. Nothing is stored, transmitted, or logged. You can verify this by using the tool offline after the page loads.
What is the difference between diff and merge?
Diff shows the differences between two texts. Merge combines changes from two texts into one — resolving conflicts where both versions changed the same section. Diff is the first step; merge is the action of reconciling those differences.
How do I read a diff output?
In a side-by-side diff, the left column shows the original text and the right column shows the modified text. Green highlighted lines are additions (new in the right text). Red highlighted lines are removals (only in the left text). Yellow highlighted lines are modifications (changed between left and right).
Can this tool handle large texts?
This tool handles texts of several thousand lines well in most browsers. For very large files (10,000+ lines), performance depends on your device. Since everything runs client-side, faster hardware processes larger diffs more smoothly. There is no server-side size limit.
Why do whitespace differences matter?
Whitespace differences (spaces, tabs, trailing spaces) are invisible but can cause issues in code, configuration files, and data formats like YAML or Python. A diff tool reveals these hidden differences that are easy to miss by eye.
What is the LCS algorithm used in diff tools?
LCS stands for Longest Common Subsequence. It is the algorithm most diff tools use to find the optimal set of changes between two sequences. By finding the longest subsequence of lines that appear in both texts (in order), the algorithm minimizes the number of additions and removals shown — producing a clean, minimal diff.