Line-by-Line · Word-level · Color Coded

Diff Checker

Compare two texts side by side to instantly see what was added, deleted, or changed. Line-by-line and word-level diff with color highlighting. No data sent to any server.

Line-by-Line Diff
Word-Level Diff
100% Client-Side
Added · Deleted · Changed
Ad · 728×90
↕️
Diff Checker — Text Comparison
Click Compare to see the diff
Ad · 728×90

Text Diff Explained

A diff (short for difference) algorithm compares two texts and identifies what changed between them. The classic algorithm, Longest Common Subsequence (LCS), finds the longest sequence of lines that appear in both texts in the same order — lines not in this sequence are either added or deleted.

The Unix diff command has been the standard for code comparison since 1974. Git, GitHub, and virtually all version control systems use diff under the hood to show what changed between commits.

How Diff Works
The Myers diff algorithm (1986) finds the shortest edit script (fewest insertions/deletions) to transform text A into text B. Lines prefixed with + were added (in B, not A). Lines with - were deleted (in A, not B). Lines with no prefix are unchanged context lines.
Line vs Word Diff
Line diff shows which entire lines changed. Word diff shows which specific words within a line changed. Word diff is more informative for prose editing — it shows "fox leaps" replaced "fox jumps" rather than just marking the whole line as changed. Git supports both with --word-diff flag.
Use Cases
Code review (finding what changed between versions), document editing (comparing draft versions), configuration management (spotting unintended changes), data validation (comparing expected vs actual output), plagiarism detection (finding identical or near-identical passages).
Privacy
This diff checker runs entirely in your browser — no text is sent to any server. This makes it safe for comparing sensitive documents, proprietary code, personal data, or confidential contracts. Close the browser tab and nothing is retained.
Frequently Asked Questions
How does a diff checker work?+
A diff checker uses the Longest Common Subsequence (LCS) algorithm or the Myers diff algorithm to find the minimum number of insertions and deletions needed to transform text A into text B. Lines that appear in both texts in the same order are "context" (unchanged). Lines only in A are "deletions." Lines only in B are "insertions." The result is displayed with color coding: green for additions, red for deletions, white/gray for unchanged lines.
What is the difference between line diff and word diff?+
Line diff marks an entire line as added or deleted if it changed at all — even a single character change shows the whole line as red (old) and green (new). Word diff goes deeper: it shows which specific words within a line changed, highlighting only the changed portion in a contrasting color. Word diff is more informative for prose and documentation. Line diff is standard for code where line-level context is more useful.
Is my text safe to compare here?+
Yes — this diff checker runs completely in your browser (client-side JavaScript). No text is sent to any server. Your content is never transmitted, logged, or stored anywhere. This makes it safe for comparing confidential documents, private code, personal data, legal contracts, or any sensitive material. Refresh the page and all content is gone — nothing is retained.
How do I compare two files?+
Open both files in a text editor, select all content (Ctrl+A or Cmd+A), copy (Ctrl+C), and paste into the respective panels. For code files: open in VS Code or any editor, select all, copy, paste. For PDFs: open in a PDF reader, select all text, copy, paste (formatting may vary). For Word documents: open, Ctrl+A, Ctrl+C, paste the plain text version. File upload is not currently supported — this tool works with pasted text.
What does the "ignore whitespace" option do?+
When "ignore whitespace" is enabled, lines that differ only in leading/trailing spaces or internal whitespace are treated as identical. This is useful when comparing code that may have been reformatted (indentation changes, trailing spaces cleaned up) without logical changes. Without this option, a line with extra leading spaces is treated as different from the same line without them. In git, the equivalent is git diff -w.
How do I compare two code files using Git?+
If the files are in a Git repository: git diff file.txt shows unstaged changes. git diff HEAD~1 HEAD file.txt compares last two commits. git diff branch1..branch2 file.txt compares across branches. For two arbitrary files not in Git: diff file1.txt file2.txt (Unix/Mac) or FC file1.txt file2.txt (Windows). VS Code has a built-in diff view: Command Palette → "Compare Active File With..."
What do the colors mean in a diff output?+
Green (+): Lines present in text B but not A — these were added. Red (-): Lines present in text A but not B — these were deleted. White/gray (no sign): Lines present in both texts — unchanged context. In word diff, green highlighting within a line shows added words; red strikethrough shows deleted words. This color convention follows the Unix diff standard and is used universally in Git, GitHub, GitLab, and all version control tools.
Can I use this to compare JSON or code?+
Yes — paste any text-based format: JSON, YAML, XML, HTML, CSS, JavaScript, Python, SQL, or plain text. For JSON specifically, consider formatting both versions first (use the JSON Formatter on this site) so the line structure is consistent and meaningful differences are more visible. For structured data, even a small change like adding a comma or changing indentation can affect many lines in unformatted JSON but only one line in properly formatted JSON.
What is a unified diff format?+
Unified diff is the standard output format of the Unix diff -u command and Git. It looks like: --- a/file.txt (original file), +++ b/file.txt (modified file), then "hunks" starting with @@ -lineA,count +lineB,count @@ showing context lines, lines starting with - (removed), and lines starting with + (added). This format is used in patch files, code review systems, and bug tracking. It's compact (shows only changed sections with context) versus showing the entire file.
How do I compare two versions of a Word document?+
Word has a built-in track changes comparison: Review tab → Compare → Compare Documents — select the two versions and Word generates a marked-up document showing all changes. For a plain-text comparison, copy the text from both Word documents and paste into this tool. Microsoft Word's native comparison is better for documents with formatting, images, and tables, since it understands the document structure. This tool is better for comparing the raw text content when you don't need Word-specific formatting insights.