How to Use the Debug Console in VS Code

Use the VS Code Debug Console to view program output, evaluate expressions, and interact with your code while paused at a breakpoint.

5 min read

The Debug Console is a REPL (Read-Eval-Print Loop) inside a running debug session. It shows your program's output. It also lets you run code interactively while execution is paused.

You do not need to add temporary print statements to your source code. You do not need to restart the debugger to test a change. The Debug Console gives you a live connection to the paused state of your program.

Open the Debug Console

The Debug Console opens automatically when you start a debug session. It appears in the panel area at the bottom of VS Code, alongside the Terminal and Output tabs.

If you closed it, reopen it with Ctrl+Shift+Y (Windows/Linux) or Cmd+Shift+Y (macOS). You can also click Debug Console in the panel tabs, or run the View: Debug Console command from the Command Palette.

The console only works during an active debug session. If no debugger is running, the input area at the bottom is grayed out and labeled "Debug session is not started."

See program output

Every print, log, or error message your program produces appears in the Debug Console while debugging. For Node.js, this includes console.log output. For Python, print statements. For browser debugging, console API calls.

The output is color-coded. Errors appear in red. Warnings appear in yellow. Standard output uses the default text color.

You can scroll through the full history and copy any line with a click.

This replaces the need to switch between VS Code and an external terminal to see what your program printed.

Evaluate expressions while paused

The Debug Console's real power is expression evaluation. While paused at a breakpoint, type any valid expression and press Enter. VS Code evaluates it in the context of the current stack frame and prints the result.

For example, if you are paused inside a function that has a variable named user, type user.email. The console prints the value on the next line.

You can chain deeper. Type user.address.city.toUpperCase() to transform a value inline.

The expression runs in the same scope as the paused line. All local variables, function parameters, and global objects are available. To inspect them without typing an expression, see how to inspect variables, watch expressions, and the call stack.

Call functions from the console

You can call functions directly from the Debug Console. If a helper function exists in scope, type its name with arguments and press Enter. The function executes immediately and the return value appears.

This is useful for testing. If your code has a function named calculateTotal, you can call it with test values:

index.jsindex.js
calculateTotal([10, 20, 30])

The function runs, returns the result, and you see it immediately. If the function modifies state, the change persists for the rest of the debug session.

Use multi-line input

Press Shift+Enter to add a new line without sending the expression. Type multiple lines, then press Enter on the final line to evaluate them all at once.

This helps when you need to declare a variable and then use it, or when a function call spans multiple lines:

index.jsindex.js
const filtered = items.filter(i => i.active)
filtered.length

The Debug Console uses the language mode of your active editor tab. If you have a JavaScript file open, the console provides JavaScript syntax highlighting, autocomplete, and bracket matching. Switch to a Python file and the console switches to Python mode.

Inspect complex objects

When you evaluate a variable that holds an object or array, the console shows an expandable tree. Click the arrow to see properties. Drill into nested objects as deep as you need.

For large objects, use the console to query specific properties instead of expanding the full tree. Type myObject.deeply.nested.property and press Enter to fetch just that value.

Change state from the console

You can assign new values to variables from the Debug Console. Type an assignment and press Enter:

index.jsindex.js
user.status = "active"

The change takes effect immediately. The VARIABLES section updates. If you press Continue, the rest of your code runs with the modified value.

This is a fast way to test fixes. If you suspect a bug is caused by a bad value, change it in the console and continue execution to see if the rest of the code behaves correctly. The change only lasts for the current session.

Troubleshooting

The console input area is grayed out

No debug session is active. Start debugging with F5 and pause at a breakpoint. The input area becomes editable when execution is paused.

Expressions return undefined or throw errors

The expression is not valid in the current scope. Check that the variable exists in the paused function. Click a different frame in the Call Stack to change the evaluation scope. If a variable is in a parent function, click the parent frame in the call stack and try again.

The console language mode is wrong

The Debug Console uses the language mode of your active editor tab. If you have a Markdown file open, the console may not recognize JavaScript or Python syntax. Switch to a code file of the correct language before using the console.

Output is not appearing

Make sure you are looking at the Debug Console tab, not the Terminal or Output tabs. The panel area shows multiple tabs. Click the dropdown arrow to switch to Debug Console, or use the View: Debug Console command.

Rune AI

Rune AI

Key Insights

  • Open the Debug Console with Ctrl+Shift+Y (Windows/Linux) or Cmd+Shift+Y (macOS). It appears automatically when you start a debug session.
  • The console shows all program output: console.log calls, print statements, and error messages appear here during debugging.
  • Type any valid expression and press Enter to evaluate it in the context of the current paused line. Results print immediately.
  • Use Shift+Enter for multi-line input. The console supports syntax highlighting and autocomplete based on your active editor's language.
  • Call functions, test return values, and inspect complex objects without modifying your source code.
RunePowered by Rune AI

Frequently Asked Questions

Why does the Debug Console show nothing when I type an expression?

You must be in an active debug session and paused at a breakpoint. The Debug Console evaluates expressions in the context of the paused line. If your program is still running or has already finished, expressions cannot be evaluated.

Can I use the Debug Console to call functions in my code?

Yes. While paused at a breakpoint, you can call any function that is in scope. Type the function name with arguments and press Enter. The function executes immediately and the return value appears in the console. This is useful for testing how a function behaves with specific inputs.

How do I enter multiple lines in the Debug Console?

Press Shift+Enter to add a new line without sending the expression. Type all your lines, then press Enter on the last line to evaluate the entire block. This works well for multi-line function calls or when you want to declare a variable and then use it.

Conclusion

The Debug Console is your interactive workspace during a debug session. It shows program output, lets you evaluate expressions in the paused context, and supports multi-line input with full language features. Use it to test fixes, call functions, and inspect complex objects without adding temporary print statements to your code. Combine it with breakpoints and logpoints for a complete debugging workflow.