Karush Logo

Compare Two Files Using Visual Studio

Highlight differences between two files using Visual Studio's file comparison functionality.

Often a person has two fairly large text files and they need to analyze the specific differences.

The is frequently done during source control activities, such as when a developer compares code that's about to be checked-in with code that is already checked.

However if just have two text files containing data, there is no simple graphical user interface in VS for comparing the files, however it's still possible by doing the following:

  1. Open Visual Studio and then open the Developer Command Prompt (Tools -> Command Line -> Developer Command Prompt), so devenv.exe is already in the path
  2. Run this command:

devenv /diff file1.txt file2.txt

This will open the two files in Visual Studio and highlight the differences, just as it does when comparing files via the source control functionality.