• google plus

How to Open HTML Files in Google Chrome from Visual Studio Code

Visual Studio Code doesn’t have a built-in method for launching HTML and other files in Google Chrome, but you can configure it to do so.

Get an Extension

As the methods shown below seem to have become outdated, we now recommend that you get an extension for launching HTML pages in your browser. The free open in browser extension works well. After installing it, restart Visual Studio Code and then right-click on any HTML page. You will have options to open in your default browser or choose another browser.Open in Browser from VS Code

Apple

Warning: this method may not work on newer versions of Visual Studio Code. If you have recently installed or updated VS Code, you should get the extension described above instead.

  1. Press CMD+Shift+P to open the Command Palette.
  2. Type "ctr" and select the Configure Task Runner command to open tasks.json.
  3. Delete the current placeholder contents.
  4. Enter the following:
    {
         "version": "0.1.0",
         "command": "Chrome",
         "osx": {
              "command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
         },
         "args": ["${file}"]
    }
  5. To test it, open an HTML file in Visual Studio Code and press CMD+Shift+B. It should open in Chrome.

Windows

Warning: this method may not work on newer versions of Visual Studio Code. If you have recently installed or updated VS Code, you should get the extension described above instead.

  1. Press Ctrl+Shift+P to open the Command Palette.
  2. Type "ctr" and select the Configure Task Runner command to open tasks.json.
  3. Delete the current placeholder contents.
  4. Enter the following:
    {
        "version": "0.1.0",
        "command": "Chrome",
        "windows": {
              "command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
         },
         "args": ["${file}"]
    }
  5. To test it, open an HTML file in Visual Studio Code and press Ctrl+Shift+B. It should open in Chrome.
Author: Nat Dunn

Nat Dunn founded Webucator in 2003 to combine his passion for technical training with his business expertise and to help companies benefit from both. His previous experience was in sales, business and technical training, and management. Nat has an MBA from Harvard Business School and a BA in International Relations from Pomona College.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, XML, Windows, Java, Adobe, HTML5, JavaScript, Angular, and much more. Check out our complete course catalog.