Code Diff Tool

Compare two code or text inputs line by line to show additions and deletions.

Category: Dev Tools

When to use?

Use it to compare code before and after edits, or to see how two versions of a config file differ.

How to use

  • Paste the original code on the left.
  • Paste the edited code on the right.
  • Added lines (green) and removed lines (red) are color-coded.

Input Explanation

Paste the original code on the left and the changed code on the right.

Calculation Basis

It builds line arrays of both strings, applies a minimum-edit-distance algorithm (Myers diff), distinguishes deletions, insertions, and unchanged lines, and renders a highlight UI.

Usage Examples

  • Check edits - Paste code before/after a change to see line-level differences.
  • Quick pre-deploy check - Check inputs and output to reduce errors before dev/ops work.
  • Aid docs/reviews - Copy the result into dev docs, issues, or review comments.

Examples

  • Original "A\nB\nC", edited "A\nX\nC" → "B" removed (red), "X" added (green)
  • Paste a function before/after a commit to see only changed lines

Cautions

  • Generated output is for reference; test carefully before production use.
  • Comparison runs only in the browser and is not sent to a server.

Guides

Line-level comparison

It compares two code/text inputs by line to show added, removed, and changed flow. Useful for small wording edits or config differences.

Compare after formatting

For structured code like JSON, HTML, CSS, and SQL, format first then compare to see the real changes more easily.

FAQ

What is the comparison basis?

A line-level diff, color-coding additions and deletions.

Is the code sent out?

No. Comparison runs only in the browser and is not sent out.

Can I see the added/removed line counts?

It tallies added and removed line counts to show the change scale at a glance.

Are whitespace differences shown as changes?

It compares by line by default, so trailing-space or indentation differences can appear as changes.

Related Tools

  • SQL Formatter - Neatly align SQL queries by keywords and clauses.
  • JavaScript Formatter - Tidy JavaScript code for readability using Prettier rules.
  • Text Compare - Compare two texts line by line to show added, removed, and identical lines.
  • JSON Formatter - Beautify or minify JSON strings instantly and check for validity errors.
  • UUID Generator - Generate up to 20 cryptographically secure UUID v4 values at once.
  • Password Generator - Generate secure random passwords in the browser by choosing length, character set, and count.