🔍 Diff Checker & Text Compare
Compare two texts side by side in your browser, nothing uploaded. Explains unified diff format and why CRLF line endings make every line look changed.
| 1 | function calculateTotal(price, tax) { | 1 | function calculateTotal(price, tax, discount = 0) { |
| 2 | const total = price + tax; | 2 | const subtotal = price - discount; |
| 3 | return total; | 3 | const total = subtotal + tax; |
| 4 | } | 4 | console.log("Total computed:", total); |
| 5 | return total; | ||
| 6 | } |
What Diff Checker & Text Compare Does
A diff finds the smallest set of changes that turns one text into another. It is not a character-by-character comparison — it solves a longest-common-subsequence problem, which is why a diff can recognize that a block moved rather than reporting the whole file as rewritten.
The granularity you choose changes what you see. A line diff marks an entire line as changed if one character differs. A word diff highlights just the altered words, which is what you want for prose. A character diff catches a single transposed letter that a line diff would bury.
Comparison here runs entirely in your browser — nothing is uploaded. That is worth stating because the market leader in this category sells a desktop application specifically so that comparisons can be done offline, which tells you what the web versions do.
How to Use Diff Checker & Text Compare
- Paste your original text or code in the left box (Before)
- Paste your modified text or code in the right box (After)
- Choose between Side-by-Side Split view or Unified line view
- Optionally toggle Ignore Whitespace or Swap sides
- Inspect highlighted additions (green) and deletions (red)
Which Granularity to Use
| Mode | Best for | Weakness |
|---|---|---|
| Line | Source code, config files, logs | A one-character edit marks the whole line changed |
| Word | Prose, documentation, contracts | Noisy on code where whitespace is significant |
| Character | Spotting a transposed letter or stray space | Unreadable on anything large |
Reading a Unified Diff
The format git, patch and most tools emit. Worth being able to read directly.
| Marker | Meaning |
|---|---|
| --- a/file | The original ("from") file |
| +++ b/file | The new ("to") file |
| @@ -12,7 +12,9 @@ | Hunk header: from line 12, 7 lines became 9 lines |
| - removed line | Present in the original only |
| + added line | Present in the new version only |
| context line | Unchanged, shown for orientation (leading space) |
| \ No newline at end of file | One version lacks a trailing newline — a real difference |
Why a Diff Shows Changes You Cannot See
When "everything changed" but nothing looks different, it is almost always one of these.
| Cause | Symptom | Fix |
|---|---|---|
| CRLF vs LF line endings | Every single line marked changed | Normalize endings, or enable "ignore line endings" |
| Trailing whitespace | Lines look identical but differ | Strip trailing spaces, or ignore whitespace |
| Tabs converted to spaces | Whole file rewritten by an editor | Check your editor's indent settings |
| Byte order mark (BOM) | Only the first line differs | Save without BOM |
| Non-breaking space | A word looks the same but is not | Character-level diff will reveal it |
| Unicode normalization | Accented characters differ invisibly | Normalize to NFC before comparing |
How to Read Your Result
CRLF is the answer most of the time
Windows ends lines with carriage-return plus line-feed; Unix and macOS use line-feed alone. A file edited on both platforms, or checked out with the wrong git autocrlf setting, differs on every line while looking identical. If a diff claims a file was entirely rewritten and the author insists they changed one line, this is why.
A diff is not a merge
Finding differences is straightforward; deciding which side wins when both changed the same region is not. That is a three-way merge, and it needs the common ancestor as well as the two versions. A two-way diff can show you a conflict exists but cannot tell you how to resolve it.
Whitespace-insensitive diffs hide real bugs
Ignoring whitespace is the right default for reviewing prose or reformatted code. It is the wrong default for Python, YAML, Makefiles and anything else where indentation is syntax — there, a whitespace-only change can alter behavior completely.
Limitations & Accuracy Notes
- Comparison happens in your browser and nothing is transmitted. Very large inputs are limited by browser memory rather than by any server limit.
- This is a two-way text diff. It cannot perform a three-way merge, and it does not understand the structure of the content — a JSON diff tool will produce more useful output for JSON, because it compares values rather than lines.
- Binary files, images and PDFs are not supported; the tool treats input as text.
- Detecting a moved block depends on the algorithm and on how far it moved. Some moves are reported as a deletion plus an addition.
- Invisible characters — zero-width spaces, non-breaking spaces, differing Unicode normalization — are genuine differences and will be reported, which is usually what you want even when it is surprising.
Frequently Asked Questions
What is a Diff Checker?
Is my text sent to any server?
Can I ignore whitespace differences?
Are my files uploaded?
Does it compare line by line or word by word?
Why does it show every line as changed?
Can it ignore whitespace?
Can I compare two files rather than pasted text?
Is there a size limit?
References & Further Reading
- POSIX — diff utility (The Open Group Base Specifications) — The normative definition of diff behavior and output formats