The Error
You hit F5 to start debugging, and VS Code throws this instead:
Unable to start debugging. Unexpected token in JSON at position 0
Sometimes the position is 0, sometimes it's 47 or 213 โ the number doesn't matter much. What matters is that VS Code can't parse your launch.json and refuses to start the debugger.
Root Cause
Before launching any debug session, VS Code reads .vscode/launch.json. One character out of place โ a trailing comma, an unclosed bracket โ and the JSON parser bails immediately.
The usual suspects:
- Trailing comma after the last item in an object or array (the most common one by far)
- Comments inside the file (
// like this) โ standard JSON doesn't allow them - Single quotes instead of double quotes around strings
- Missing or extra curly braces / square brackets
- Unescaped special characters in string values
- The file is empty or got truncated โ that's the classic "position 0" case
Fix: Step-by-Step
Step 1 โ Open launch.json directly
Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run Open launch.json. Or just navigate to .vscode/launch.json in the Explorer panel โ whichever is faster for you.
Step 2 โ Check the Problems panel
VS Code has a built-in JSON validator. With launch.json as the active file, open the Problems panel (Ctrl+Shift+M). You'll see something like:
Trailing comma [json(trailingComma)]
Comments are not permitted in JSON [json(jsonc)]
Click the error โ VS Code jumps straight to the broken line. That alone solves it 80% of the time.
Step 3 โ Fix the most common issues
Trailing comma (most frequent)
Bad:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js", // โ trailing comma here
}
]
}
Good:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js"
}
]
}
Comments in JSON
Standard JSON has no comment syntax โ full stop. Strip them out:
// Bad
{
"version": "0.2.0", // this is the schema version
...
}
// Good
{
"version": "0.2.0",
...
}
One gotcha: VS Code internally uses JSONC (JSON with Comments) for its own config files. If launch.json is associated with the wrong language mode, comments will trigger the error even though they'd normally be fine. Glance at the bottom-right status bar โ it should say JSON with Comments, not plain JSON. Click to change it if needed.
Single quotes
// Bad
{
'version': '0.2.0'
}
// Good
{
"version": "0.2.0"
}
Unmatched brackets
Click on any { or [ โ VS Code highlights the matching closing bracket. Work through the file top-to-bottom and find the one that has no match.
Step 4 โ Validate with an external tool
If the Problems panel shows nothing but the error persists, the file may have invisible characters or encoding issues that fool VS Code's validator. Paste the contents into JSON Formatter & Validator on ToolCraft โ it runs entirely in the browser (nothing gets uploaded) and shows the exact line and character position. Faster than reading through the file by eye.
Step 5 โ Reset launch.json from scratch
Sometimes the file is mangled enough that fixing it line by line isn't worth the effort. Just start over:
# Delete the broken file
rm .vscode/launch.json
Then go to Run โ Add Configuration. VS Code generates a valid launch.json template for your project type. Re-add only the customizations you actually need โ nothing more.
Step 6 โ Check for a BOM character
"Position 0" specifically is a red flag for a BOM (Byte Order Mark) โ an invisible character that some editors silently prepend to files. It's invisible in VS Code but breaks JSON parsing immediately. Check the encoding shown in the status bar: it should say UTF-8, not UTF-8 with BOM.
To strip it: Command Palette โ Change File Encoding โ Save with Encoding โ pick UTF-8 (no BOM).
Verify the Fix
- Save
launch.jsonafter your edits. - Confirm the Problems panel shows zero errors for the file.
- Press F5 โ the debugger should launch without the modal error.
- The Debug Console panel opens and shows your program output.
Prevention
- Use Add Configuration instead of typing by hand. The Run menu's Add Configuration option inserts valid JSON snippets directly โ no typos, no missing commas.
- Lint in CI. If
launch.jsonlives in version control, runjq . .vscode/launch.jsonas a CI step. It exits non-zero on any JSON error, so broken configs never make it to the repo. - Turn on Format on Save. Settings โ search Format On Save โ enable it. It won't fix structural errors, but trailing commas get caught immediately when you save.
- Keep the JSONC language mode active. The status bar should always show JSON with Comments for
launch.json, not plain JSON. This enables comments and gives you IntelliSense for debug configuration properties. - Keep a validator handy. Bookmark ToolCraft's JSON Formatter โ it's the quickest way to sanity-check any config file you've edited manually.

