Learn how to use ESP IoT Development Framework with Visual Studio Code, together with ESP-IDF VSCode Extension. Setup, build, flash and monitor your application

ESP IoT Development Framework (ESP-IDF) in Visual Studio Code

Learn how to use ESP IoT Development Framework with Visual Studio Code, together with ESP-IDF VSCode Extension. Setup, build, flash and monitor your application

Firmware & Frameworks
Last Updated:

We have already compared the two most popular development frameworks for ESP32 and ESP8266 boards. If you picked ESP-IDF, Espressif's own Visual Studio Code extension is the most complete way to use it - free, actively maintained, and it wraps the whole build-flash-monitor-debug workflow behind the VS Code Command Palette.

Coming from the Arduino IDE? See the comparison between Visual Studio Code and Arduino IDE first - in short, we prefer VS Code once a project outgrows a single sketch file, mostly for the editor and debugging tools.

25-35 minutes Free and open source Espressif's own framework

1Getting the development stack ready

To develop with ESP-IDF in Visual Studio Code you need the editor itself, a couple of build prerequisites, and Espressif's extension. Then it's one more command to pull down ESP-IDF and its toolchain.

  1. Download and install Visual Studio Code. It runs on Windows, macOS and Linux; platform-specific install steps are here.
  2. Install the ESP-IDF build prerequisites for your OS.
  3. Open VS Code, select the Extensions icon in the left sidebar (Shift+Cmd+X on Mac), search for ESP-IDF, and install the official extension published by Espressif Systems.

Windows

No additional prerequisites - the Installation Manager in the next step installs everything ESP-IDF needs.

macOS and Linux

Install the OS packages ESP-IDF's build system needs before continuing - see Espressif's Linux and macOS prerequisites guide. Full OS-by-OS detail is also in the extension's own README.

Espressif IDF Visual Studio Code extension listing in the Marketplace
The Espressif IDF extension in the VS Code Marketplace - search "ESP-IDF" and install the one published by Espressif Systems

2Configure the extension

With the extension installed, open the Command Palette (View -> Command Palette, or Shift+Cmd+P on Mac) and run ESP-IDF: Open ESP-IDF Installation Manager. This downloads the ESP-IDF framework itself, its toolchain, and sets up a Python virtual environment for it - pick the ESP-IDF version you want to install and let it run.

ESP-IDF extension setup downloading ESP-IDF, its toolchain and a Python environment
ESP-IDF, its toolchain and a Python environment downloading. The exact panel has changed release to release (this one predates the current standalone Installation Manager), but the three things it installs have not.

When it finishes, you will see a confirmation that setup is complete and you can start using the extension. The Installation Manager is also available as a standalone download if you would rather run it outside VS Code first. Full walkthrough: official ESP-IDF VS Code extension install guide.

Recommended: install the C/C++ extension too. For proper syntax highlighting, code navigation and suggestions, install Microsoft's C/C++ extension the same way - search "C/C++" in the Extensions view and restart VS Code after installing. ESP-IDF projects already ship a working .vscode/c_cpp_properties.json, so it should work without extra setup.

Microsoft C/C++ extension in the VS Code Marketplace
Microsoft's C/C++ extension - not required, but worth installing for IntelliSense in ESP-IDF projects

With the extension configured, let's create, build and flash the "blink" example so you can confirm the whole toolchain works end to end.

  1. Open the Command Palette and run ESP-IDF: New Project. Choose ESP-IDF as the framework, then find blink under the "get-started" examples. Click Create project using example blink, pick a folder on your computer, and the extension opens the new project in VS Code.
  2. Set your target chip: run ESP-IDF: Set Espressif Device Target and pick your chip from the list - esp32, esp32s2, esp32c3 (used on boards like the XIAO ESP32-C3), esp32s3, and others. If you skip this step, the target defaults to esp32.
  3. Select your USB port: run ESP-IDF: Select Port to Use (COM, tty, usbserial) and choose the port your board is connected to. Not sure which one it is? Unplug the board, repeat the command, and see which port disappeared from the list.
  4. Build the project: run ESP-IDF: Build Your Project. This opens a terminal and starts the build - a successful build ends with a summary of program sizes.
  5. Flash it: run ESP-IDF: Flash Your Project. The default flashes over UART; you'll see upload progress in the terminal, ending with a hash-verified confirmation.
  6. Watch and listen: the board's built-in LED should start blinking. Run ESP-IDF: Monitor Device to see the matching log output in a terminal.
Selecting the ESP32 target chip in the Espressif device target picker
Picking a target chip after running ESP-IDF: Set Espressif Device Target
ESP-IDF Flash task terminal output showing a successful flash
A successful flash - "Hash of data verified" and "Hard resetting" mean it worked
ESP-IDF Monitor terminal showing the blink example's serial output
The blink example's log output in ESP-IDF Monitor

One command for all three. Once your target and port are set, you can skip running build, flash and monitor separately - ESP-IDF: Build, Flash and Start a Monitor on Your Device runs all three in sequence from a single Command Palette entry.

If you plan to debug over JTAG later, you will also run into an OpenOCD board-configuration picker (reached via ESP-IDF: Select OpenOCD Board Configuration) that lists the debug adapters for your chip. It is unrelated to basic UART flashing above and only matters once you start debugging.

ESP-IDF OpenOCD board configuration picker for an ESP32-C3
Choosing an OpenOCD board configuration for JTAG debugging on an ESP32-C3 - a separate, optional step from the UART flashing above

Built-in LED not blinking? Make sure the example is configured for your board. Run ESP-IDF: SDK Configuration Editor (Menuconfig), search for "blink" in the search bar (or open Example Configuration from the left menu), and check two things:

  • Under Blink LED type, pick RMT - Addressable LED if your board has an addressable built-in LED, otherwise GPIO.
  • Under Blink GPIO number, set the pin that matches your board's built-in LED (or any GPIO, if you wired up your own LED).
ESP-IDF SDK Configuration editor showing the blink example's LED type and GPIO settings
The blink example's settings in the SDK Configuration editor

More detail on daily use of the extension: official ESP-IDF VS Code extension project guide.

Additional tools provided by ESP-IDF

Size analysis

After a build, run ESP-IDF: Size Analysis of the Binaries to see how much flash and RAM your application uses - handy for keeping an eye on how close you are to a microcontroller's limits.

ESP-IDF Explorer

The Espressif icon in the Activity Bar opens the ESP-IDF Explorer: device partitions, app trace, RainMaker, eFuse, and documentation search results all live here.

Docs search

Select any part of your code, then run ESP-IDF: Search in Documentation.... Matches show up under "ESP-IDF Docs Search Results" in the Explorer and link straight to the relevant page.

ESP-IDF Size Analysis tool showing binary size breakdown
ESP-IDF Size Analysis - flash and RAM usage for the built binary
ESP-IDF Explorer sidebar with documentation search results
ESP-IDF Explorer, showing documentation search results after running ESP-IDF: Search in Documentation...

The same ESP-IDF: New Project wizard you used to create the blink example also offers templates from other frameworks configured in the extension - for example, "arduino-as-component" gives you a project where you can write Arduino Core code inside an ESP-IDF application.

ESP-IDF New Project template picker showing arduino-as-component and other templates
Template options inside the New Project wizard, including "arduino-as-component"

ESP-IDF Visual Studio Code cheat sheet

We have covered several commands in this guide - here they are together, using the current command names, to keep bookmarked. Open the Command Palette with View -> Command Palette or the shortcut Shift+Cmd+P on macOS (check your OS's shortcut next to "Command Palette" in the View menu), then type the command name. Frequently used commands also show a keyboard shortcut next to them in the palette.

Build, flash and monitor

  • ESP-IDF: Build, Flash and Start a Monitor on Your Device - run all three steps in sequence
  • ESP-IDF: Build Your Project
  • ESP-IDF: Flash Your Project
  • ESP-IDF: Monitor Device

Creating projects

  • ESP-IDF: New Project - create a project from an ESP-IDF example or an extension template

Configuration

  • ESP-IDF: Set Espressif Device Target
  • ESP-IDF: Select Port to Use (COM, tty, usbserial)
  • ESP-IDF: SDK Configuration Editor (Menuconfig)
  • ESP-IDF: Select Flash Method - choose UART, DFU or JTAG
  • ESP-IDF: Open ESP-IDF Installation Manager - only needed for initial setup, or to add/change an ESP-IDF version

Other useful commands

  • ESP-IDF: Size Analysis of the Binaries
  • ESP-IDF: Search in Documentation...
  • ESP-IDF: Doctor Command - prints a diagnostic report, useful when asking for help
ESP-IDF commands in the VS Code Command Palette
The ESP-IDF command list in the Command Palette. This capture is from an older extension release - some of the names shown here (Show Examples Projects, Create project from extension template, Configure ESP-IDF extension) have since been renamed or merged; use the verified names above instead.

There are several more commands provided by the ESP-IDF VS Code extension - the ones above cover the basics of building, flashing and monitoring ESP32 microcontrollers.

Frequently asked questions

Do I need to install ESP-IDF separately before using the VS Code extension?
No. Install the Espressif IDF extension from the VS Code Marketplace, then run ESP-IDF: Open ESP-IDF Installation Manager from the Command Palette - it downloads ESP-IDF itself, the toolchain, and sets up a Python environment in one step.
What happened to the ESP-IDF: Show Examples Projects command?
It was merged into ESP-IDF: New Project. That single command now opens a project-creation wizard covering both ESP-IDF's own examples and templates from other frameworks configured in the extension, such as Arduino-as-component.
How do I build, flash and monitor an ESP-IDF project in one step?
Run ESP-IDF: Build, Flash and Start a Monitor on Your Device from the Command Palette. It runs the build, flash and monitor steps in sequence, as long as you have already set your target chip and serial port at least once.
Do I need to configure UART or JTAG separately when flashing?
Not by default. Running ESP-IDF: Flash Your Project flashes over UART unless you choose otherwise. To flash or debug over JTAG or DFU instead, use ESP-IDF: Select Flash Method, or one of the dedicated Flash (UART), Flash (DFU) or Flash (with JTAG) commands.
Is the ESP-IDF VS Code extension free?
Yes. The extension, ESP-IDF itself, and Visual Studio Code are all free and open source. Espressif publishes the extension on the VS Code Marketplace under an open source license.

Where to next