Oh MyUtils

Diff Checker - Compare Text & Find Differences Online

Compare two texts side by side and highlight differences line by line. Supports unified and split view modes with character-level diff highlighting.

View
Diff Mode
Options
Original
Modified
Output
No differences

Frequently Asked Questions

What is a Diff Checker?

A diff checker is a tool that compares two texts and highlights the differences between them. It shows additions (new content), deletions (removed content), and modifications. This is essential for code review, document editing, configuration debugging, and version comparison.

How does the diff algorithm work?

The diff algorithm uses the Longest Common Subsequence (LCS) approach to find the optimal set of changes between two texts. It identifies the longest sequence of characters or lines that appear in both texts, then marks everything else as additions or deletions.

What's the difference between Side-by-Side and Unified view?

Side-by-Side view shows both texts in parallel columns, making it easy to compare corresponding lines. Unified view combines both texts into a single column with + and - prefixes, similar to Git diff output. Side-by-Side is better for visual comparison, while Unified is more compact.

What are Line, Word, and Character diff modes?

Line mode compares texts line by line - if any part of a line changes, the entire line is marked. Word mode highlights individual word changes within lines. Character mode shows the most granular differences, highlighting each changed character. Use Line for code, Word for prose.

Is my data safe when using this tool?

Yes, all processing happens 100% in your browser. Your texts are never sent to any server. You can safely compare sensitive documents, code, or confidential information without privacy concerns.

Code Examples

import { diffLines, diffWords } from 'diff';

const original = 'Hello World';
const modified = 'Hello JavaScript World';

// Line diff
const lineDiff = diffLines(original, modified);
lineDiff.forEach(part => {
  const prefix = part.added ? '+' : part.removed ? '-' : ' ';
  console.log(prefix, part.value);
});

// Word diff
const wordDiff = diffWords(original, modified);
wordDiff.forEach(part => {
  if (part.added) console.log('Added:', part.value);
  if (part.removed) console.log('Removed:', part.value);
});

Related Tools