Skip to content
ZeroServer.tools

Text Diff & Code Compare

100% private. All differential analysis happens securely in your browser.

Load file
Load file
View Layout
Diff Precision
Comparison Resultslines level diff
1-// Sample original code
1+// Sample modified code
2-function calculateTotal(price, tax, discount) {
2+function calculateTotal(price, tax, discount = 0) {
3- const subtotal = price + tax;
3+ const subtotal = price * (1 + tax / 100);
4 const total = subtotal - discount;
4 const total = subtotal - discount;
5+
6+ if (total < 0) return 0;
5 return total;
7 return total;
6}
8}
7
9
8console.log(calculateTotal(100, 10, 5));
10console.log(calculateTotal(100, 10, 5));
Added: +5 linesRemoved: -3 linesUnchanged: 5 lines

How does Client-Side Diff work?

This tool computes the differences between two strings using the Myer's Diff algorithm. By comparing the text directly inside your browser window, your source code, configuration files, and sensitive credentials never touch any external API, ensuring absolute privacy.

Diff Modes Explained

  • Line Diff: Compares files line-by-line. Perfect for source code file revisions and system configuration updates.
  • Word Diff: Compares files word-by-word. Ideal for prose, copy edits, document proofreading, or markdown content.
  • Character Diff: Highlights changes down to individual character letters, showing the most granular shifts, typos, or white-spaces.

Built and maintained by Meet Shah · Last updated

What this tool is used for

  • Finding the one changed value between two API responses that should be identical.
  • Comparing a config file against a known-good copy after an incident.
  • Checking exactly what a formatter or a codemod changed before accepting it.
  • Spotting an invisible character difference between two strings that look the same.
  • Reviewing a paste from a colleague against your own version line by line.

How it works in practice

A worked example

A review shows one line removed and one added, and you need to know whether the change is to the discount or to the whole expression.

Input
Original:  const total = subtotal - discount;
Modified:  const total = subtotal - discount * 2;
Output
Lines precision
  -  const total = subtotal - discount;
  +  const total = subtotal - discount * 2;

Words precision
     const total = subtotal - discount 
  +  * 2
     ;

Line precision can only say the whole line went and another arrived, which is true and tells you nothing. Word precision splits the same comparison into three pieces and marks exactly one of them as added, so the answer is visible without reading either line: everything up to the discount is untouched, the multiplication is new, and the semicolon at the end is the old one. On a long line of dense expression that difference is the whole value of the tool, and it is a setting rather than a mode you can miss.

The edge case that catches people

A diff explains a change with the shortest edit script it can find, and shortest is not the same as what you actually did. Add a duplicate of a line that already exists and the algorithm has two equally brief explanations to choose between — it keeps the first copy as unchanged and marks the second as the addition, whichever one you typed. The comparison is correct and the attribution is arbitrary, which matters the moment you use a highlighted position to decide who changed what and when.

When not to use this tool

For reviewing code, git already does this better than any text box can: it detects renames, follows a file through them, and gives you surrounding context that turns a diff into something readable. Two structured documents want comparing as parsed values rather than as characters, because key order and indentation are formatting rather than change. And this page has real ceilings — character precision stops computing above 30,000 characters of combined input and word precision above 200,000, quietly falling back to lines, because those algorithms are quadratic and would otherwise take the tab with them.

Frequently Asked Questions

What does a diff tool do?
A diff compares two blocks of text line by line and highlights what changed — added lines in green, removed lines in red. It uses the same comparison format as git diff.
Does my text get sent to a server?
No. Both inputs and the diff computation run entirely in your browser. Your text never leaves your device — safe for comparing confidential documents or private source code.
What's the difference between word diff and line diff?
Line diff marks entire lines as added or removed. Word diff highlights the specific words within a changed line, making it easier to spot small edits in long paragraphs.
Why do some lines appear changed when the content looks identical?
Trailing whitespace or different line endings (Windows CRLF vs Unix LF) look the same visually but differ byte-by-byte. Toggle 'Ignore whitespace' to strip these differences.
Can I compare source code files?
Yes. Paste any plain text: source code, JSON, config files, SQL, or prose. The output is a standard unified diff you can copy and share.

Common errors and gotchas

  • Diffing files with different line endings, which marks every line as changed and hides the real difference.
  • Comparing formatted against unformatted text, where the whitespace noise buries the one real change.
  • Reading a character-level diff on reordered content, where a move shows as a delete plus an insert.
  • Assuming a clean diff means identical files. Trailing whitespace and a final newline may be ignored by the view.
  • Diffing two JSON documents whose keys are in different orders and treating the result as a change in data.

Related Formatters & Validators tools

Private & free — this tool runs entirely in your browser.

IndieKitShip your Next.js startup in days.affiliate