Skip to content

Diff Checker – Compare Text Online

Updated:

Paste two texts or load .txt files and instantly see every added, removed and changed line highlighted in green and red. Get line counts, a similarity score and a standard unified diff to copy — everything runs locally in your browser.

Compare Two Texts and Highlight Every Difference

Input Fields
Comparison options
If enabled, the result will update automatically when you change any value.

Diff Checker Formula

Formula
\[ \begin{aligned} D &= N + M - 2L \\ S &= \mathrm{round}\!\left(\frac{200C}{N+M}\right)\,\% \end{aligned} \]

Where:

  • \(D\) — size of the shortest edit script: the smallest number of line deletions and insertions that turns text A into text B
  • \(N\), \(M\) — number of compared lines in the original (A) and the changed (B) text
  • \(L\) — length of the longest common subsequence (LCS) of matching lines shared by both texts
  • \(C\) — number of line pairs the two texts have in common (unchanged lines)
  • \(S\) — the similarity percentage shown in the summary badge

The calculator finds \(D\) with the Myers O(ND) algorithm — the same algorithm family that powers git diff and GNU diff. Its cost grows with the size of the difference rather than the size of the files, which is why two long but nearly identical documents compare almost instantly.

Diff Checker – Calculation Example

Example: the two pre-filled texts. Text A contains 5 non-blank lines after the empty line in the middle is skipped (the "Skip blank lines" option is on by default); text B contains 6 lines.

The line diff marks three regions of change. The first lines share every word except one, so they are paired and the second pass narrows the difference down to a single word: jumps in A becomes leaps in B — one changed line, highlighted on both sides. The third line of A ("The five boxing wizards…") shares no words with the third line of B ("Sphinx of black quartz…"), so it counts as one removed and one added line rather than one change. The final line of B is brand new — one more added line.

Result: 2 lines added, 1 line removed, 1 line changed, 3 unchanged.

The similarity badge is \( \mathrm{round}\left(\frac{200 \cdot 3}{5+6}\right) = 55\% \), and the "Copy unified diff" button produces a standard patch in diff -u format covering all three changes.

How to use the calculator

  1. Paste the original version into Original text (A), or click 📂 Load original .txt to read a file straight from your device.
  2. Paste the edited version into Changed text (B), or click 📂 Load changed .txt. The comparison refreshes the moment you type.
  3. Pick a View: Side by side shows both versions in parallel columns; Unified (inline) lists removed and added lines one after another.
  4. Choose the Highlight detail: Per word marks whole words that differ, Per character narrows it down to every single character.
  5. Set the comparison options: Ignore whitespace (lines equal if they differ only by spaces or tabs), Ignore letter case (Hello = hello), and Skip blank lines (empty lines are dropped before comparing).
  6. Read the results: summary badges with added/removed/changed/unchanged counts and a similarity score, the color-coded diff view, and a standard unified diff you can copy. Use ⇄ Swap texts to reverse the direction and ✕ Clear both to start over.

What a diff checker is and how to read the result

A diff checker (also called a text comparison or merge tool) finds the smallest set of edits that turns one text into another. Instead of reading two versions line by line yourself, you paste both and the tool marks exactly what was added, deleted or modified. It is the standard way to review edits to contracts, essays, code, configuration files, translations or any text that exists in more than one version.

The color code follows the convention used by git and every code editor: green means added (the line exists only in the changed text), red means removed (the line exists only in the original), and a red-green pair on the same row is the same line before and after editing — with the exact differing words or characters highlighted inside. Two texts with no differences at all produce a green "identical" message instead.

The summary badges give you the scale of the change at a glance: how many lines were added, removed, changed and left untouched, plus a similarity percentage. A 98 % similarity means the two versions share 98 % of their line pairs (counted across both texts, so 100 % requires both texts to be equal). This is handy for quick questions like "how much did this document actually change between drafts?" without inspecting every highlight.

The unified diff block is the plain-text standard format that diff -u and git diff print: @@ -start,count +start,count @@ heads each hunk, lines starting with - come from the original and lines starting with + from the changed text. Save the copied output as a .patch file and tools like patch or git apply can apply the changes to a file automatically.

Assumptions, limits and practical tips

  • Comparison is line-based. The tool works on whole lines, then highlights words or characters inside matched line pairs. Reformatting a paragraph into different line lengths will show many changed lines even if the wording is identical.
  • The ignore options change equality, not your text. "Ignore whitespace" collapses runs of spaces and tabs and trims line edges before comparing; "Skip blank lines" also changes the line numbers, which then count only the non-blank lines that were actually compared.
  • Folded context is a display feature. Runs of more than 8 identical lines are folded behind a "⋯ N identical line(s) folded ⋯" counter with 3 context lines on each side. The summary and the copied unified diff always count and contain every line.
  • Size limits. The comparison handles up to 30,000 lines combined (about 15,000 per side) and roughly 1.2 million characters total; fully rewritten regions larger than a few thousand lines are compared as whole blocks to keep the page responsive.
  • Everything stays private. Both textareas and both .txt buttons run entirely in your browser via the standard FileReader interface — no text or file is ever uploaded to a server.
  • Useful companions: Duplicate Lines Remover to clean up lists before comparing them, Character Counter to check text length across versions, and JSON Formatter to pretty-print JSON files so line-based diffing works well. For prose, the Case Converter fixes inconsistent capitalization before you compare.

Frequently Asked Questions

What similarity percentage means the two texts are basically the same?

There is no universal threshold — it depends on what you are reviewing. For contracts or legal documents, even 99% similarity deserves a close look at the highlighted lines, because a single changed word can matter. For essays or drafts, anything above roughly 90% usually means light editing, while scores under 70% indicate substantial rewriting. Treat the badge as a scale indicator and always check the actual highlighted changes before drawing conclusions.

Why are two similar lines sometimes shown as one removed plus one added line instead of one change?

A removed and an added line are paired as a "change" only when they share enough words (the tool needs them to be at least 40% similar at the word level, ignoring case). If a line was rewritten so heavily that most words differ, the line diff sees no meaningful match, so it reports one deletion and one insertion. That is also why other tools may group the same edit slightly differently — pairing heuristics vary.

Why does my prose show every line as changed when I only re-wrapped the paragraphs?

The comparison works line by line, so it is word-wrapping sensitive. If you reflowed a paragraph onto lines of different length, every line boundary moved and almost no whole line matches anymore, even though the wording is identical. Line-based diffing is designed for texts with stable line breaks (code, lists, configuration). To compare reflowed prose effectively, put each sentence or paragraph on one long line before pasting.

Does the tool handle Windows, Mac and Linux line endings correctly?

Yes. Carriage returns from Windows files (\r\n) and old Mac files (\r) are normalized to plain \n before splitting, so a text saved on Windows compares cleanly against the same text saved on Linux. You will not see phantom differences caused by invisible line-ending characters. One caveat: a trailing newline at the end of one file but not the other can still make the final lines differ if "Skip blank lines" is off.

Can I compare Word documents, PDFs or Excel files with this tool?

Not directly — it accepts plain text and text-like files (.txt, .md, .csv, .json, .code, .log and similar). For a .docx or .pdf, first copy the text out and paste it into the two boxes; formatting, images and tables are lost, but the wording is compared fine. For Excel or CSV data, paste the rows as text or save as .csv, keeping one record per line so the line-based comparison lines up.

How do I use the copied unified diff to apply the changes to a file?

Save the copied text into a file named something.patch, put it next to the original file, then run patch original.txt < something.patch on Linux/macOS or git apply something.patch inside a Git repository. The header line says which positions each hunk edits: lines starting with - are removed, + lines are inserted, and the @@ -start,count +start,count @@ markers locate each block in both versions.

Is my text or file safe, or is it uploaded to a server?

Nothing leaves your device. Both pasted texts are compared entirely inside your browser tab, and the file buttons use the standard local FileReader interface — the file is read into memory, never sent over the network. You can verify this yourself by disconnecting from the internet after the page loads: pasting, editing and comparing keep working exactly the same. This makes it suitable for confidential drafts, contracts or credentials-containing config files.

Leave a Reply

Your email address will not be published. Required fields are marked *