Skip to content

Everything runs in your browser. We never see your code. How we prove it →

Code Diff — Compare Code Online

Drop two versions of a source file below. Language is detected for you, and the comparison never leaves this tab.

Original
Changed

How code comparison works

Your two snippets enter the engine as plain text, and the alignment that comes back is a Myers shortest edit script — no parser stands in front of it. Highlighting is a separate, later pass: once the lines are paired, the page samples the input for a shebang, an XML prolog, a package or import block, a curly-brace-and-semicolon rhythm, matches that against roughly forty grammars, and pulls in only the one it needs. Colour never changes which lines are marked; it only makes the marked ones legible. One consequence is worth knowing before you paste: matching is textual. Run Prettier, black or gofmt across a file first and every line the formatter touched will register as changed, even where behaviour is identical. When the real question is structural rather than textual — a payload whose keys were reordered by a serializer — JSON Diff answers it properly.

Two columns are the default here because indentation is easier to read in parallel, with the panes scroll-locked; the unified view is one keystroke away when you want the change to read top to bottom. Any unchanged stretch longer than eight lines folds up, leaving three lines of context on each side, so a 3,000-line generated client collapses to the handful of edits a schema bump actually produced. Once you have read the change and want to hand it to somebody else's working tree, the Patch Generator turns the same two inputs into a unified diff with headers and context depth you control.

Your source never leaves this tab

Source code is the one thing many engineers are contractually forbidden to paste into a stranger's server: client work under NDA, an unreleased feature branch, the auth middleware nobody outside the team has read. DiffViewer removes the question rather than answering it. There is no upload control, no snippet ID, no stored history that could ever be handed over, and the only bytes this page fetches while you work are the grammar file for whichever language it detected. Open your browser's network tab while you use this tool — you'll see no request carries your content. Here is how to verify that yourself.

When developers reach for this

  • A reviewer auditing a messy rebase sets the file as it stands after the rebase against the copy saved beforehand, to confirm that a conflict someone resolved at midnight kept both sides of the logic.
  • An engineer chasing an undocumented fork compares the library sitting in vendor/ with the pristine release tarball and finds the two lines a colleague patched in 2021 and never wrote down.
  • A platform engineer reading generated output diffs yesterday's API client against today's regeneration. Collapsed unchanged regions reduce four thousand machine-written lines to the six that the schema change caused.
  • A developer working outside version control pastes a snippet from a Slack thread beside the file on disk, on a laptop where the repository was never cloned, just to check whether the fix already shipped.
  • An instructor grading submissions lines a student's implementation up against the reference to see which parts were reasoned through and which were copied verbatim from the lecture notes.

Frequently asked questions

Which languages get highlighted?

Around forty, including JavaScript and TypeScript, Python, Go, Rust, Java, C, C++, C#, Ruby, PHP, Swift, Kotlin, SQL, shell, HTML, CSS, YAML and Dockerfiles. Detection reads the content itself, so a pasted fragment with no filename still colours correctly, and you can override the guess from the language menu when a snippet is too short to be recognised.

Does my code get sent to a server for highlighting?

No. Both the diff and the tokenizer run as JavaScript inside your tab. Loading a grammar is an outbound request for a static asset — it sends nothing about your snippet. Watch the network panel while you paste and you will see the grammar fetch and nothing else; the verification walkthrough shows what to look for.

How much code can I compare in one go?

Live recomparison covers up to 1 MB combined; past that the page switches to an explicit Compare button so typing stays responsive. Around 10 MB per side is comfortable, with 50 MB as the hard ceiling. Beyond about thirty thousand lines the engine moves to a line-mode strategy that trades some intra-line detail for speed.

Why does a reformat show up as a change everywhere?

Because comparison is on text, not on an abstract syntax tree. If only indentation moved, turn on ignore-whitespace and those lines drop out of the result. Reflowed argument lists and rewrapped strings are genuine textual edits, though, so those will stay marked no matter which normalization options you enable.

Can I get something I can apply, not just read?

Yes — export writes a standard unified diff from whatever is currently in the two panes. If you need control over the file headers or want more or fewer than three context lines around each hunk, use the Patch Generator, which exposes both.