Code Diff Online

Compare source code files side by side and find differences instantly.

ORIGINAL1 lines
MODIFIED1 lines

When a browser code diff is the right tool

Not every review starts in a repository. You might have two versions of a function in a chat thread, a take-home assignment and the file the candidate sent later, a SQL script from a colleague, or a production hotfix pasted next to the copy still on your laptop. In those cases, creating a branch just to see the difference is slower than it needs to be.

This page is for that gap: two snippets, a clear side-by-side highlight, and no need to invent a project around them. When the code already has history, git diff is the better tool. The two jobs should not be mixed up.

Use cases

Reviewing a paste that never became a pull request

A teammate drops an old function and a rewritten one into a message. You need to know whether they only added a default argument, or also changed the return path. Pasting both sides and reading the marked lines is usually enough to decide whether the change is safe to accept, without checking the snippet into Git first.

Comparing generated or exported code

Formatters, code generators, and “export to SQL” dialogs often produce two files that differ in ways that are hard to see in a scrolling editor. A line diff shows whether the generator also changed a type, a constraint, or just the wrapping.

Checking a hotfix against the laptop copy

Incident changes sometimes live in a terminal history or a gist before they are committed. Comparing that paste with the file you still have locally answers a narrow question: what exactly did we change in production? Once you know, the right next step is still a proper commit — this page only helps you see the edit.

How the comparison works

Code Diff compares the two panes as plain text, line by line. It does not parse JavaScript, Python, or any other grammar, and it does not add syntax highlighting. That is deliberate. A language-agnostic line diff stays predictable: an identical line stays aligned, a line only on the left is removed, a line only on the right is added. You can switch between split and unified views and copy the result.

Because the unit is the line, a small edit inside a line — a renamed variable, a new default argument, a flipped flag — appears as one removed line and one added line. If you need the changed tokens themselves marked, use word mode on the homepage text diff or the inline text diff.

Example — a default argument and a new return format
function greet(name) {
  return "Hello, " + name
}

function greet(name, greeting = "Hello") {
  return `${greeting}, ${name}!`
}

In the sample above, the function name is unchanged and the body is not a rewrite from scratch. A line diff should show the new greeting parameter and the template literal on the return line, not a whole new function. Load the built-in sample on the tool if you want a slightly longer JavaScript example already filled in.

What this tool does not do

It does not understand renames, move detection, or coverage. It will not compile the code, run tests, or apply a patch. It does not talk to GitHub or GitLab. And it should not be used as a place to paste secrets: comparison is local to the browser, but the snippet is still on your screen and in memory until you clear it or close the tab.

How to use Code Diff

  1. Paste the older version into the original pane, or load the sample to see the layout.
  2. Paste the newer version into the modified pane. Keep indentation consistent on both sides if you can.
  3. Choose Compare. Use split view for a function-level read, and unified view when you want a compact plus-and-minus list.
  4. Swap the sides if you pasted them in the wrong order, copy the result if you need a record, and Clear when you are finished.

Frequently asked questions

Which programming languages does Code Diff support?

Any language that you can paste as text: JavaScript, TypeScript, Python, Go, Java, C, C++, Rust, SQL, shell, and others. The tool does not parse a language grammar. It compares lines, so a change is visible in the same way for every language.

Does the result include syntax highlighting?

No. The panes are monospaced text with added and removed lines marked. That keeps the comparison language-agnostic and easy to scan. If you need highlighting, review the change here first, then open the file in an editor.

Is this a replacement for git diff?

No. Use Git when the code already lives in a repository and you care about history, branches, or a patch you can apply. Use this page when you have two snippets that are not in a repo yet: a paste from chat, a take-home file, or a hotfix next to the copy on your laptop.

Is my code sent to a server?

No. Comparison runs in your browser, and closing the tab discards the paste. Still, do not paste secrets, private keys, production credentials, or customer data. If you would not put the snippet in a chat message, do not put it here.

Can I compare files I have on disk?

You can open the files in an editor and paste them, or use the File Diff tool if you prefer to select files from your computer. Nothing is uploaded in either case. Very large files may be slower in the browser than a local git diff --no-index.

Why did a small edit light up the whole line?

This page compares line by line. A renamed variable or a flipped boolean on an otherwise unchanged line is marked as one removed line and one added line. For a closer look at the words that changed, use the homepage text diff in word mode, or the inline text diff tool.

Is there a file size limit?

There is no server-imposed limit. A few thousand lines is comfortable. Multi-megabyte generated files can make the tab feel slow; compare a reduced excerpt or use a local tool in that case.

Related tools and guides

References

  • The unified diff format in GNU diffutils. The + / - convention in the unified view comes from this family of tools. The result on this page is a readable view, not necessarily a patch file you can feed to patch.
  • When the code already lives in Git, use git diff or git diff --word-diff. An online tool fills the gap outside a repository; it is not a substitute for version control.