Somebody sends you "the fixed version" of a function and you want to see what they actually touched. Or a config works on staging and fails in production, and the two files look the same at a glance. Paste both versions above, pick the language if it isn't guessed right, and press Compare code. Changed lines are colored, and inside each line the exact characters that differ are marked, so a moved comma or a swapped variable name is hard to miss.

How to compare two versions of code

  1. Put the older version in Original code and the newer one in Changed code. You can paste, or use Open file above either box.
  2. Check the Language menu. Opening a file sets it from the file extension; for pasted code it stays on what you chose, or on Auto-detect.
  3. Press Compare code. The editor loads in place of the boxes, with both versions side by side.
  4. Keep working in the editor: fix a line on either side, switch to a single unified column, or go back to the boxes to start over.

The example buttons load small before-and-after pairs in JavaScript, Python, SQL, Java and CSS. They are worth one click if you want to see what the result looks like before you paste anything of your own.

Why the language setting matters

The diff itself doesn't care about the language. Lines are compared as text, so a Kotlin file or a Terraform module compares just as correctly as JavaScript. What the language changes is the highlighting, and that matters more than it sounds: with colors on, a string that lost its closing quote or a line that turned into a comment jumps out immediately, while in plain text it looks like any other edit.

Auto-detect recognizes about ten common languages from the text, among them JavaScript, Python, Java, C, C++, Go, PHP, HTML and CSS. It guesses from short snippets, and a ten-line SQL query or a JSON fragment can come out as something else. If the colors look wrong, pick the language by hand: the menu has 17 of them, including TypeScript, C#, Rust, SQL, JSON, YAML and XML.

Hiding changes that are not changes

Most noisy diffs come from formatting, not from logic. One person's editor converted tabs to spaces, another one's added a trailing newline, and now every line is red and green. The editor has three ways out of that, and they solve different problems.

Ignore Whitespace (under Options) stops counting leading and trailing spaces, so a re-indented block no longer shows as rewritten. Format runs Prettier over both sides; it handles JavaScript, TypeScript, HTML, CSS, JSON, YAML, Markdown and GraphQL, and is the right choice when one version was minified or wrapped differently. Normalize sorts JSON keys and CSS properties and evens out whitespace, which helps when two API responses hold the same data in a different order.

A word of caution about Normalize: sorting keys is fine for comparing data, but don't copy normalized code back into a project without looking. Property order in CSS can change which rule wins.

Reading the diff

Red on the left is what the original had and the new version doesn't; green on the right is what was added. A line that changed shows up on both sides, with the edited characters in a darker shade. The small map on the right edge of the editor shows where all changes sit in a long file.

To walk through the changes one by one, use the arrows above the editor or Alt+Up and Alt+Down (Option on a Mac). In a long file, Show Diff Only hides the unchanged parts and keeps a few lines of context around each change; you choose how many. Copy Diff puts the differences on the clipboard, so you can paste them into a ticket or a chat.

The default algorithm, Smart Diff, is the one VS Code uses. It is good at matching moved and lightly edited lines. If it pairs lines in a way that looks odd, the Classic (LCS) method sometimes gives a cleaner picture for heavily rewritten code.

When a browser diff is the wrong tool

If both versions are already in a Git repository, git diff or your IDE will show the change with history attached, and you won't need to copy anything. Our guides to git diff between two files and comparing files in VS Code cover both. A three-way merge of conflicting branches also belongs in Git or a merge tool, since this page only compares two sides.

Where pasting wins is everything outside the repository: a snippet from a code review comment, two answers from Stack Overflow, a query copied out of a log, a config pulled from two servers, or the output of an AI assistant that rewrote "just one function." It is also the fastest code difference checker to reach when you are on a machine without your usual tools.

For language-specific advice, see the guides on comparing SQL and JSON, or the explainer on the unified diff format if you need to send a patch.

What happens to your code

Code is often the one thing you are not allowed to paste into random websites, so here is exactly what this page does. The two texts travel from the boxes to the editor inside the URL fragment (the part after #), which browsers never send to a server. The comparison runs in your tab. The editor keeps a history of recent comparisons in your browser's storage, and you can delete any entry from the History window.

The one feature that sends anything out is AI Summary. It is off until you paste your own OpenAI API key into its settings, and even then it runs only when you press it. If your code is under a strict policy, don't set it up.

Frequently asked questions

Which languages does the code diff support?

Syntax highlighting covers JavaScript, TypeScript, Python, Java, C#, C and C++, Go, Rust, PHP, SQL, HTML, CSS, JSON, YAML, XML, Markdown and shell scripts. The diff itself works on any text, so code in other languages still compares correctly line by line, just without colors.

Is my code uploaded anywhere?

No. The page hands your code to the editor inside the same browser tab, and the comparison runs there. Nothing is sent to a server unless you set up AI Summary with your own OpenAI API key and press it; then the two texts go to OpenAI to be summarized.

Can I compare two files instead of pasting?

Yes. Use Open file above either box, or open the editor and use Open Files in its Options menu. Files up to about 1 MB go through the boxes on this page; bigger ones should be opened in the editor itself.

How do I ignore indentation and trailing spaces?

In the editor, open Options and switch the diff method from Smart Diff to Ignore Whitespace. Lines that differ only in leading or trailing spaces stop showing as changed. If the two versions were formatted differently, press Format first.

Can I edit the code after comparing?

Yes. Both sides stay editable and the diff updates as you type. The arrow in the gutter next to a changed block copies that block back from the original, which is handy when you want to undo one change and keep the rest.

Compare code without opening this page

The same editor is a free Chrome extension. It opens from the toolbar, can compare the source of two open tabs, and keeps your recent comparisons.

Add Diff Checker to Chrome