Original

Modified

Paste text into both fields above to see the diff.

How to Use the Diff Checker

Paste your original text into the left field and your modified text into the right field. The diff is computed automatically and shown below, with green lines for additions and red lines for removals.

What is a Diff?

A diff (short for difference) is a comparison between two versions of a text. It shows which lines were added, removed, or left unchanged. Diffs are used in version control systems like Git to track code changes over time.

Use Cases

  • Code review — Compare two versions of a function or file before merging.
  • Config changes — Spot differences between two configuration files.
  • Document editing — See what changed between two drafts of a document.
  • Log analysis — Compare log outputs from two runs to find discrepancies.
  • API response comparison — Diff two JSON responses to catch unexpected changes.
  • SQL query tuning — Compare query plans or output sets between two versions.

How the Diff Algorithm Works

This tool uses the Longest Common Subsequence (LCS) algorithm to find the minimal set of changes between two texts. LCS identifies the longest sequence of lines that appear in both versions in the same order, then marks everything else as added or removed.

The Unix diff command and Git both use variants of this approach (Git uses the Myers diff algorithm by default). The result is a compact, human-readable change summary that highlights only what actually changed.

Tips for Better Diffs

  • Normalize whitespace first — Extra spaces or tabs at line endings create false differences. Trim your input if you only care about content changes.
  • One logical unit per comparison — Compare a single function, config block, or paragraph at a time for cleaner output.
  • Use for JSON — Format both JSON objects with consistent indentation before diffing to get meaningful line-level differences.
  • Check line endings — Windows (CRLF) and Unix (LF) line endings can produce unexpected diffs. Convert to the same format first.

Related Guides

FAQ

Is my data safe?

Yes. All comparison happens in your browser using JavaScript. No text is ever sent to a server.

What kind of diff does this tool produce?

It produces a line-by-line diff using the Longest Common Subsequence (LCS) algorithm, similar to the Unix diff command.

Can I compare code files?

Yes. Paste any text — code, prose, configs, or logs — and the tool will highlight added, removed, and unchanged lines.

Can I compare JSON?

Yes. For best results, format both JSON objects with consistent indentation before pasting. This ensures the diff highlights meaningful content changes rather than formatting differences.

What is the difference between unified and side-by-side diff?

A unified diff shows both old and new lines interleaved in a single column, prefixed with - (removed) and + (added). A side-by-side diff shows the two versions in parallel columns. This tool uses a unified format for compact, scannable output.

Related Articles