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.