visual-studio without tfs - Compare two files in Visual Studio

8 Answers

You can try VSCommands extension from Visual Studio Gallery. Latest release allows you to select two file and compare them:

not source control

I saw new comparsion tool in VS 2012 for comparing two files or two versions of file. I like it. But when I tried to find it I can't because I don't use TFS. Is there a way how can I just compare two files with builtin feature in VS but without TFS?

In Visual Studio 2012, 2013, 2015, you can also do it with Web Essentials, just right click the files and from context menu > Web Essential >> Diff selected files:

Edit: It's now available as a separate extension

Command Window (CTRL+ALT+A)

Tools.DiffFiles File1 File2

File Comparer VS Extension by Akhil Mittal. Excellent lightweight tool that gets the job done.

To compare any two files and merge it to one file Here are the following steps you can follow if you have visual studio(Any version) installed.

Step 1: Open Visual studio command prompt. If you do not find visual studio command prompt then choose visual studio tools

Start -> Visual studio command prompt

Step 2: Enter the command vsdiffmerge.exe

Ignore the switch /m if you need just comparison.

Syntax 1:
vsdiffmerge <file1> <file2> <file1> <outputfile> /t /m

Syntax 2:
vsdiffmerge <basefilename> <CompareFilename> <basefilename> <OutputFilename> /t /m

Example 1:
vsdiffmerge test1.js test2.js test1.js output.js /t /m
Example 2:
vsdiffmerge.exe "C:\Users\livingston\Downloads\wa\wa\Files\pre\Test.js" "C:\Users\livingston\Downloads\wa\wa\Files\Prod\Test.js" "C:\Users\livingston\Downloads\wa\wa\Files\pre\Test.js" "C:\Users\livingston\Downloads\wa\wa\Files\output\samp.js" /t /m

Step 3: Merge the files

Please note that if file name does not exists in the location, it will not open the comparer.

Also you can beautify the file before you do the comparison. In visual studio Ctrl + K + D.

There are lot of beautifier sites available online.

If you are working with TFS connected then right click on file which you need to compare (through source control explorer) and it presents you a window like this -

Now change path of source file in 'Souce Path:' and you get comparision through VS comparision tool.

Similarly you can compare folder also which compares all files of a folder at once.