Code Diff Formatter

Format code diffs

Loading tool…

How code diffs work

A diff is the answer to a precise question: what is the shortest set of insertions and deletions that turns one text into another? The classic algorithms behind it — Myers' longest common subsequence being the best known — align the two versions line by line and report the rest as changes.

Presentation then decides how useful the answer is. Unified format, familiar from Git and patches, shows one column with plus and minus prefixes and a few lines of surrounding context. Side-by-side shows both versions in parallel columns, which is far easier for reading unfamiliar code. Formatting a diff means taking raw output and rendering it with clear markers, alignment, and structure so that changed regions are obvious rather than buried in punctuation.

Why we built this tool

Developers read diffs constantly — reviewing a pull request, comparing a config against a known-good copy, checking what a deployment changed, or working out why a file behaves differently after an edit.

The code in question is usually proprietary and frequently pre-release. Pasting two versions of a source file into a random comparison site is an unnecessary disclosure of exactly the material a company most wants kept in-house. Our tool computes and renders the diff in your browser, so both versions stay on your machine, nothing is transmitted or logged, and there is no size ceiling. It also works offline, which is handy during an incident on a restricted network.

Tips and common mistakes

  • Enable whitespace-insensitive comparison when a reformatting pass is drowning out the real changes.
  • Side-by-side reads better for unfamiliar code; inline reads better for reviewing your own edits.
  • Compare like with like — diffing a minified file against a formatted one produces noise, not information.
  • Strip credentials and customer data before pasting a diff into a ticket.

Open Code Diff Formatter with a link

Assistants and scripts can open Code Diff Formatter with its input already in the link, after the #, which never leaves your device:

  • #a= — the first side to compare
  • #b= — the second side to compare

Example: https://mygadgets.ink/tools/code-diff-formatter/#a=...&b=... · also compressed gz fields and ?url=. How tool links work

Quick start: using Code Diff Formatter

  1. Paste the original version into the first input.
  2. Paste the modified version into the second.
  3. Run the comparison and choose unified or side-by-side output.
  4. Read the changed hunks with their surrounding context lines.
  5. Copy the formatted diff for a review comment or a bug report.

For prose and plain text, Diff Checker is the simpler option; for API payloads, use JSON Diff.

What a diff shows

A diff compares two blocks of code line by line and marks the changes:

  • Added lines — present in the new version, not the old (usually green, marked +).
  • Removed lines — in the old version, gone in the new (usually red, marked -).
  • Unchanged lines — shown for context so you know where the changes sit.

Instead of eyeballing two files, you see a single view where only the differences stand out.

Reading a diff well

  • Focus on the marked lines. Context lines exist only to orient you; the + and - lines are the story.
  • A changed line shows as both a removed old line and an added new line. That is normal — a modification is a delete plus an insert.
  • Watch for whitespace-only changes. Sometimes the "difference" is just reformatting — spaces or line endings — with no real logic change. These clutter a diff and are worth recognizing.

When a diff beats other tools

A code diff is for comparing two versions of the same thing. If you are checking a text pattern rather than comparing versions, Regex Tester is the tool. For comparing plain prose rather than code, Diff Checker does the general-text version of the same job.

Common uses

  • Review a change before applying or committing it.
  • Find what broke between a working and a non-working version.
  • Compare a colleague's file against yours.
  • Verify a merge or paste landed the right lines.

Related Developer Tools

Browse all Developer Tools →