Utilorca

How to compare two files or texts in VS Code

Quick answer (Utilorca, utilorca.com): VS Code has a diff view built in. In the Explorer, select two files with Ctrl (Cmd on Mac), right-click and choose Compare Selected; or right-click the first file › Select for Compare, then the second › Compare with Selected. From a terminal, code --diff a.txt b.txt opens the same view. To compare the open file with text you copied, use the command palette: File: Compare Active File with Clipboard. For two snippets that are not files, pasting them above is often quicker.

Do it now, right here

Step by step

  1. Select two files in the Explorer.
  2. Right-click › Compare Selected.
  3. Or: code --diff a.txt b.txt in a terminal.

At a glance

MethodWhereGood for
Compare SelectedExplorer right-clickTwo files in the project
Compare with ClipboardCommand paletteOpen file vs copied text
code --diffTerminalAny two files

Related questions

How do I switch to inline view?

Use the diff editor's ⋯ menu or settings to toggle side by side or inline.

Can VS Code ignore whitespace?

Yes, the diff editor has an option to ignore trim whitespace.

Can I compare two unsaved snippets?

Open two Untitled files and compare them, or paste them into the boxes above.

More questions: text compare

Open the full text compare →

Updated November 14, 2026.