How to Diff Two Files in VS Code

Published April 2025 · 3 min read

Method 1: Right-Click (Easiest)

  1. In the Explorer sidebar, right-click the first file
  2. Click "Select for Compare"
  3. Right-click the second file
  4. Click "Compare with Selected"

Method 2: Command Palette

  1. Open both files in tabs
  2. Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
  3. Type "Compare Active File With..."
  4. Select the other file

Method 3: Terminal

code --diff file1.js file2.js

Compare with Git Version

Click the file in Source Control sidebar to see changes vs last commit. Or use:

code --diff HEAD:file.js file.js

Online Alternative

Use our Diff Checker for quick text comparison without VS Code.

Related