How to Debug Code in VS Code
Advertisement
Ad
Debugging in VS Code
VS Code has a powerful built-in debugger — far better than scattering console.log everywhere. Here's how to use it.
Step 1: Set a Breakpoint
Click in the gutter (left of line numbers). A red dot appears — execution will pause there.
Step 2: Start Debugging
Press F5, or click Run → Start Debugging
# For Node.js, select "Node.js" environment
Step 3: Control Execution
| Action | Key |
|---|---|
| Continue | F5 |
| Step Over | F10 |
| Step Into | F11 |
| Stop | Shift + F5 |
Step 4: Inspect Variables
When paused, hover over variables to see values, or check the Variables panel on the left.
launch.json for Custom Setups
{
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "Debug App",
"program": "${workspaceFolder}/index.js"
}]
}
FAQs
Debugger or console.log?
The debugger lets you inspect everything at any point without editing code. More in our how-to guides.
Can I debug in the browser?
Yes — with the JavaScript Debugger for Chrome/Edge.
