Diff Checker

Compare two versions of any text or code line by line. Removed lines are marked in red, added lines in green, with line numbers and counts. Everything runs in your browser.

Text Comparison
Original Text 0 chars
Modified Text 0 chars
Added: 0 Removed: 0 Unchanged: 0 Original Lines: 0 Modified Lines: 0

When a line-by-line diff helps

Two versions of a config file, a contract clause that came back from review, a function before and after a refactor, two exports of the same list: when you need to know exactly which lines differ, reading both side by side is slow and error-prone. This checker lines up the Original Text and the Modified Text, marks every line that was removed or added, and counts what stayed the same. It works with any plain text, including source code, CSV rows, log output and prose.

How to compare two texts

  1. Paste the older version into Original Text on the left and the newer version into Modified Text on the right. The character count above each box updates as you type.
  2. Click Compare. The Diff Result panel opens below and the page scrolls to it.
  3. Read the result: each row shows the line number in the original, the line number in the modified text, a - or + marker and the line itself. Removed lines are red, added lines green, unchanged lines plain.
  4. Check the stats bar for the number of added, removed and unchanged lines, plus the total line count of each version.
  5. Use Copy Diff to copy the whole result as text, with + , - or two spaces in front of each line. Swap exchanges the two boxes, Sample loads a small JavaScript example, and Clear resets everything.

How the comparison works

Both texts are split at line breaks, and the page computes the longest common subsequence (LCS) of the two line lists with the classic dynamic-programming table. Lines in that common subsequence are reported as unchanged; everything else in the original is reported as removed and everything else in the modified text as added. Within each gap between matching lines, removals are listed before additions. The result uses the fewest possible added and removed lines, the same goal as git diff, although Git uses a different algorithm (Myers) and can occasionally align equal-sized changes differently.

Lines must match exactly to count as unchanged. That has a few practical consequences:

Frequently asked questions

Is my text uploaded anywhere?

No. The comparison is JavaScript running on this page; neither text is sent to a server or saved in your browser. It is fine to compare confidential drafts, although, as always, avoid pasting passwords or keys.

How large can the texts be?

The LCS table has one cell for every pair of lines, so memory grows with the product of the two line counts. A few thousand lines per side compares quickly; tens of thousands of lines on both sides can make the tab slow or run out of memory. For very large files, use a desktop diff tool or git diff --no-index.

Can I get a unified diff or patch file?

No. Copy Diff produces a simple marked list without the @@ hunk headers that patch or git apply expect, so it is meant for reading and sharing, not for applying changes.

Why are lines that look identical marked as changed?

They usually differ in invisible characters: trailing spaces, tabs versus spaces, a non-breaking space, or a carriage return from Windows line endings. Normalising whitespace in your editor before pasting removes these false differences.

Related tools

Copied!