Code Diff Checker

Paste the old and new version of your code. Both sides are formatted the same way first, so a reformat or a minified copy no longer shows up as “everything changed” — only the edits you actually made are highlighted.

Original

Changed

+0 added−0 removed~0 changed0 unchanged

How a diff is found: the longest common subsequence

A diff checker doesn’t compare line 1 with line 1. It looks for the longest sequence of items the two versions share in the same order; everything outside that sequence is an addition or a deletion. Real diffs do this with whole lines — here it’s letters so the table fits. Change the words and step through it.

SKIRTS
0000000
S0
H0
I0
R0
T0

Press “Next cell”. Each cell answers: how many letters do the two prefixes have in common, in order?

Git and this tool use Eugene Myers’ 1986 algorithm, which finds the same answer without filling the whole table — important when files have thousands of lines.

How to compare code online

  1. Paste the original on the left and the changed code on the right, or drop a file on either pane.
  2. Leave Ignore formatting on. The language is detected and both sides run through the same formatter (Prettier for JS/TS/HTML/CSS/YAML/GraphQL/Markdown, dedicated formatters for JSON, SQL and XML).
  3. Read the result: green lines were added, red removed, and changed words inside a line are marked. Press Ctrl/⌘+Enter to jump to it.
  4. Tick Only changes to fold away unchanged code, then Copy diff or download a .patch for git apply.

Why formatting noise ruins a normal diff

A line-based diff compares text, not meaning. If one copy was minified, re-indented from 4 spaces to 2, or had its quotes changed by a formatter, almost every line differs and the one real edit is buried. Normalising both sides with the same formatter puts them in the same shape first, so the diff lines up again. If either side does not parse, the tool says so and falls back to a plain line diff.

Code diff vs. diff checker vs. JSON compare

UseWhen
Code diff (this page)Two versions of source code that may be formatted differently.
Diff checkerAny plain text — prose, logs, config — compared exactly as typed.
JSON compareData: ignores key order and lists changes by path such as items[2].qty.

Questions

How do I compare two code files online?

Open or drop one file on each side (any text file works), keep “Ignore formatting” on, and the differences appear immediately. Nothing is uploaded — the diff runs in your browser with the open-source jsdiff library.

Can it ignore whitespace and indentation?

Yes. “Ignore formatting” re-formats both sides with the same rules, which removes indentation, line-wrapping, quote-style and semicolon differences. For text that is not code, use “Ignore whitespace” on the diff checker.

Which languages are supported?

JavaScript, TypeScript, JSON, HTML, CSS, SCSS, SQL, XML, YAML, GraphQL and Markdown are formatted before comparing. Any other language (Python, Go, Java, PHP…) still gets an exact line and word diff — just switch “Ignore formatting” off.

How is this different from git diff?

git diff compares committed files in a repository. This page compares any two snippets you paste, with word-level highlighting, and can export a unified .patch that git apply accepts.

How do I compare code in VS Code instead?

Select two files in the Explorer, right-click and choose “Compare Selected”, or run code --diff a.js b.js from a terminal.

Related tools