My site is ad supported.

How to Run JSMin from within Visual Studio

To easily (and non-destructively) run all the Javascript files in your Visual Studio project through the JSMin tool with no additional utilities, you simply need to leverage the power of the command line from within Visual Studio's External Tools configuration.

What this command does:

  1. Searches the respective Visual Studio's project directory for all files matching the pattern "*.min.js" and deletes them.
  2. Each *.js file found in the project directory, is run through jsmin.exe with the output placed in the file "<filename>.min.js".

Important Note: If you have any files in your project matching the pattern ".min.js", you should adjust the command accordingly by replacing ".min" (two locations) with something else - otherwise your ".min.js" files will be deleted.

Before following these steps, you should have jsmin.exe on your system and in a folder defined in the PATH variable (if in doubt, just place it in your Windows folder).


  1. Go to Tools > External Tools...
  2. Add a new tool with the following settings:
    • Title: JS Min
    • Command: cmd.exe
    • Arguments (long string all on a single line - spacing is very important):
      /V:ON /C DEL /S /Q "$(ProjectDir)\*.min.js"&FOR /F "usebackq tokens=* delims=" %A IN (`DIR /B /S "$(ProjectDir)\*.js"`) DO @SET Min="%~dpnA.min.js"&ECHO !Min!&jsmin < "%A" > !Min!
    • Initial Directory: Location of jsmin.exe
    • Check options: Use Output window & Close on exit
  3. Now whenever you want to run the process, just go to Tools > JS Min.
  4. Because the option for Use Output window is selected, you can see the results in the output display.

My site is ad supported.