How to Compare Two Files in VS Code

VS Code has a diff editor built in, with three different ways to open it depending on what you're starting from: two saved files, one open file plus a file you haven't opened yet, or a file against whatever's currently on your clipboard.

Quick answer

Select two files in the Explorer sidebar (click one, Ctrl/Cmd-click the second), right-click, and choose Compare Selected. Or with one file open, run File: Compare Active File With... from the Command Palette (Ctrl+Shift+P) and pick the second file. Use F7 and Shift+F7 to jump between changes. For unsaved or pasted text, use two Untitled tabs, or skip the editor entirely and paste into a browser-based diff tool.

Compare Selected: two files in the Explorer

In the Explorer sidebar, click the first file, then hold Ctrl (Cmd on Mac) and click the second file so both are selected. Right-click either one and choose Compare Selected. VS Code opens its diff editor with the two files side by side - this is the quickest route when both files already exist on disk and you can see them both in the sidebar.

Compare Active File With...

Open the file you want to compare, then press Ctrl+Shift+P (Cmd+Shift+P on Mac) to open the Command Palette and run File: Compare Active File With.... Pick the second file from the list that appears. This is faster than the Explorer method when the second file is somewhere you'd have to navigate to manually, since it opens VS Code's file picker instead.

Comparing against the clipboard

With a file open, run Compare Active File with Clipboard from the Command Palette. VS Code diffs the open file against whatever text is currently on your clipboard, without needing to paste it into a file first - useful for checking whether a config file matches something you copied from a colleague's message or a documentation page.

Navigating the diff editor

Press F7 to jump to the next change and Shift+F7 for the previous one. The scrollbar gutter shows markers for every change location so you can see roughly how many differences there are and where, without scrolling through the whole file. The ... menu in the top right toggles between side-by-side view (default) and inline view, which shows removed lines struck through directly above the added lines in a single column.

Comparing unsaved or pasted text

Neither file needs to exist on disk. Open two new tabs with Ctrl+N (Cmd+N on Mac), paste one block of text into each, then select both in the Open Editors section of the Explorer and run Compare Selected - or use Compare Active File With... and choose the other untitled tab from the list. This is the closest VS Code gets to a pure paste-and-compare workflow.

When to skip VS Code entirely

VS Code's diff editor is worth using when the files already live in your workspace or you're mid-edit and want an in-editor comparison. For a quick one-off check of two blocks of text - especially if you're not at your usual machine, or the text isn't saved anywhere yet - pasting both directly into a browser-based diff tool is faster than opening an editor and creating two tabs first. And if your everyday Windows editor is Notepad++ rather than VS Code, it can compare two files with its Compare plugin.

Paste two blocks of text and see the difference instantly.

Open Text Diff →

Want more on comparing text online?

See the full guide to comparing text online, including download options.

Read the guide →

Frequently Asked Questions

How do I compare two files in VS Code using the Explorer?
In the Explorer sidebar, click one file, then Ctrl-click (Cmd-click on Mac) the second file to select both. Right-click either one and choose Compare Selected. VS Code opens its built-in diff editor with both files side by side.
How do I compare files with the command palette instead?
Open the file you want to compare, press Ctrl+Shift+P (Cmd+Shift+P on Mac) to open the Command Palette, and run File: Compare Active File With... Pick the second file from the list, and VS Code opens the diff editor with the active file as one side and your selection as the other.
Can I compare a file against the clipboard in VS Code?
Yes. With a file open, run the command Compare Active File with Clipboard from the Command Palette. This is useful for checking whether a file matches something you copied from elsewhere - a Slack message, an email, or another editor - without saving that content to a file first.
How do I navigate between changes in the VS Code diff editor?
Press F7 to jump to the next change and Shift+F7 for the previous one, without needing to scroll manually. The diff editor also shows a minimap-style change indicator in the scrollbar gutter so you can see roughly where all the differences are at a glance.
Can I switch between side-by-side and inline diff view in VS Code?
Yes. Click the ... (more actions) menu in the top right of the diff editor and toggle Inline View. Inline view shows both versions in a single column with removed lines struck through above the added lines, which some people find easier to read for small changes; side by side is the default and generally better for larger changes.
Can I compare two blocks of unsaved text in VS Code?
Yes - open two new Untitled tabs (Ctrl+N / Cmd+N), paste one block of text into each, then select both tabs in the Explorer's Open Editors section (or use Compare Active File With... and choose the other untitled tab) and run Compare Selected. Neither file needs to be saved to disk first.
Is comparing two files in VS Code the same as git diff?
Related but not identical. VS Code's built-in Source Control view uses the same diff editor to show changes against your last git commit automatically, with no manual file selection needed - click a changed file in the Source Control panel and it opens the diff against HEAD. Compare Selected and Compare Active File With... are for comparing any two arbitrary files, whether or not they're tracked by git.
What if I want to compare text without opening VS Code at all?
For a one-off comparison, especially of text that isn't already saved as a file, pasting both blocks directly into a browser-based diff tool is faster than opening an editor, creating two tabs, and running a command. It works on any device and needs nothing installed.

Share this tool

Featured on ToolDirs
© 2026 ListDiff

Free online list and text processing tools.