Skip to main content
smnify.

Diff Checker

Paste an original and an updated version to see exactly which lines were added, removed or changed. View the result side by side or as a unified diff, highlight changes inside a line by word or character, ignore whitespace or case, and download the result as a .diff file. Your text stays in your browser.

Runs in your browser

Free, no sign-up. Both texts are compared in your browser. Nothing is uploaded, stored or sent in analytics; usage events record only that a comparison ran.

Advanced Diff Checker

Compare code or text from any programming language with side-by-side and unified diff views.

Inline

Similarity

33%

Added

+4

Removed

-2

Changed

2

Unchanged

3

Old
Original
New
Updated
1
function calculateTotal(items) {
2
return items.reduce((sum, item) => {
3
return sum + item.price;
1
function calculateTotal(items, taxRate = 0) {
2
const subtotal = items.reduce((sum, item) => {
3
return sum + item.price * item.quantity;
4
}, 0);
4
}, 0);
5
6
return subtotal + subtotal * taxRate;
5
}
7
}
6
8
7
console.log(calculateTotal(cart));
9
console.log(calculateTotal(cart, 0.18));

How to use the Diff Checker

  1. Paste the old text into Original and the new text into Updated. Sample loads an example, Swap exchanges the two sides, Clear empties them.
  2. Choose Inline Word or Character to set how changes inside a line are highlighted, and tick Ignore whitespace or Ignore case if those differences do not matter.
  3. Switch between Side by side and Unified to read the result. The counters show Added, Removed, Changed, Unchanged and a Similarity percentage.
  4. Set Context to 0, 1, 3, 5 or 10 lines to control how much surrounding text the unified diff includes.
  5. Press Copy diff to copy the unified diff, or Download .diff to save it as changes.diff.

Worked example

Sample data

Input
Original:
function total(items) {
  return items.length;
}

total(cart);

Updated:
function total(items, tax = 0) {
  return items.length * (1 + tax);
}

total(cart, 0.18);
Output
--- Original
+++ Updated
@@ -1,5 +1,5 @@
-function total(items) {
-  return items.length;
+function total(items, tax = 0) {
+  return items.length * (1 + tax);
 }
 
-total(cart);
+total(cart, 0.18);

Default options, Context 3, unified output. The counters read Added 1, Removed 1, Changed 2, Unchanged 2 and Similarity 40%. Similarity is the unchanged lines divided by the larger line count.

How it works

How the comparison works

Both texts are split into lines and compared with a longest common subsequence (LCS) table, a dynamic-programming method that finds the largest set of lines that appear in the same order in both versions. Lines outside that set are the additions and removals.

Because the table has one cell per pair of lines, the work grows with the product of the two line counts. To keep your browser responsive, inputs that need more than 4,000,000 cells, or that contain a line over 2,000 characters, are not compared and the tool shows a warning instead.

table cells = old lines x new lines

Changed lines and inline highlights

A removed line that sits directly next to an added line is shown as a changed row, and the part that differs is highlighted. In Word mode whole words are marked; in Character mode individual characters are marked.

Only adjacent pairs are matched. In a long run of removed lines followed by a long run of added lines, some lines can appear as plain removals and additions rather than changes.

Ignore whitespace and ignore case

Ignore whitespace treats runs of spaces and tabs as equal, so re-indented lines are not reported as changes. Ignore case compares letters without regard to capitals.

These options affect which lines are considered equal. They are useful for formatting-only edits but can hide a real change, so switch them off when exact text matters, for example in Python or YAML.

The unified diff format

A unified diff starts with --- and +++ header lines, then hunks that begin with @@ -start,count +start,count @@. Lines starting with - were removed, lines starting with + were added, and lines starting with a space are unchanged context.

The Context setting only changes how many unchanged lines surround each change in this unified output and the downloaded file. The side-by-side view always shows the full text.

Inputs, outputs and limits

Inputs

  • Original text or code
  • Updated text or code
  • Options: inline Word or Character, ignore whitespace, ignore case, context lines, view mode

Outputs

  • Side-by-side or unified diff view
  • Added, removed, changed and unchanged counts plus a similarity percentage
  • A unified diff to copy or download as changes.diff

Limits

  • Comparison is skipped when old lines x new lines exceeds 4,000,000
  • Comparison is skipped when any line is longer than 2,000 characters
  • Compares text line by line; it does not understand language syntax or moved blocks
  • Context lines affect only the unified diff and download

Processing

  • Both texts are compared in your browser. Nothing is uploaded, stored or sent in analytics; usage events record only that a comparison ran.

Frequently asked questions

Is the text I paste sent to a server?

No. The comparison runs in your browser and neither version is uploaded or saved. That makes it suitable for private code, though you should still avoid pasting secrets.

Why was my comparison skipped?

The tool refuses inputs where the line counts multiplied together exceed 4,000,000 cells, or where a single line is longer than 2,000 characters, because the comparison would use too much memory. Split the files or remove very long lines such as minified code.

What is the difference between Word and Character inline mode?

Word mode highlights whole changed words, which reads well for prose and code. Character mode highlights single changed characters, which is better for spotting small typos or one-digit changes.

Does Ignore whitespace change the downloaded diff?

Yes. With the option on, lines that differ only in spaces or tabs count as unchanged, so they do not appear as changes in the copied or downloaded diff.

Can I apply the downloaded .diff file with git or patch?

It is a standard unified diff with generic Original and Updated headers rather than real file paths. Tools like patch may need you to name the target file or edit the headers first.

Does it detect moved blocks of code?

No. It is a line-by-line comparison, so a block moved elsewhere shows as removed in one place and added in another.

Need a custom internal tool or integration?

We build internal tools, APIs and integrations that fit your team's workflow, from a single admin screen to a full backend.