Last Updated:
How to Fix VS Code 'Unable to Write into User Settings' Error (JSONC 514: Expected Comma in settings.json)
If you’ve ever tried to customize your Visual Studio Code (VS Code) settings—whether to tweak the editor theme, adjust font size, or enable auto-save—you might have encountered a frustrating error: “Unable to write into user settings” accompanied by a cryptic message like “JSONC 514: Expected comma”. This error stops you from saving changes to your settings.json file, leaving your desired configurations unapplied.
But fear not! This error is almost always caused by a simple JSON syntax mistake—specifically, a missing comma between properties in your settings.json file. In this blog, we’ll break down what causes this error, how to diagnose it, and step-by-step how to fix it. By the end, you’ll be able to resolve the issue in minutes and prevent it from happening again.
Table of Contents#
- Understanding the Error: What is JSONC 514?
- Step-by-Step Fix Guide
- Preventing Future Errors
- Conclusion
- References
Understanding the Error: What is JSONC 514?#
Before diving into the fix, let’s demystify the error message:
- “Unable to write into user settings”: VS Code cannot save your
settings.jsonfile because it contains invalid syntax. - “JSONC 514: Expected comma”:
JSONCstands for “JSON with Comments,” the format VS Code uses forsettings.json(it allows comments, unlike strict JSON). The error code514specifically indicates that the JSON parser expected a comma (,) between two properties but didn’t find one.
Why Does This Happen?#
settings.json is a JSONC file, which means it follows strict syntax rules. In JSON, each key-value pair (property) must be separated by a comma—except after the last property in an object. For example:
{
"editor.fontSize": 14, // Comma required after this line (since another property follows)
"editor.theme": "Dark+" // No comma needed here (last property)
} If you forget a comma between properties (e.g., between "editor.fontSize": 14 and "editor.theme": "Dark+"), VS Code’s JSON parser throws the “Expected comma” error.
Step-by-Step Fix Guide#
Let’s walk through resolving the error with clear, actionable steps.
Step 1: Access the settings.json File#
First, open the problematic settings.json file. There are two ways to do this:
Option A: Via the Command Palette#
- Open VS Code.
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) to open the Command Palette. - Search for and select: “Open User Settings (JSON)”.
This will directly open your user settings.json file in the editor.
Option B: Via the Settings UI#
If you prefer a visual interface first:
- Open VS Code’s Settings UI by pressing
Ctrl+,(Windows/Linux) orCmd+,(Mac). - In the top-right corner of the Settings UI, click the “Open Settings (JSON)” button (it looks like a document with a JSON icon).
This will open settings.json in the editor.
Step 2: Locate the Syntax Error#
Once settings.json is open, VS Code will highlight the error. Look for:
- A red squiggly line under the problematic code.
- An error message in the bottom status bar (e.g., “Problems: 1”).
- Details in the Problems panel: Press
Ctrl+Shift+M(Windows/Linux) orCmd+Shift+M(Mac) to open it. The panel will show the exact line number and error description (e.g.,Line 5: Expected comma).
Step 3: Fix the Missing Comma#
Now, navigate to the line mentioned in the error (e.g., Line 5). Let’s use an example to illustrate:
Example of Invalid settings.json (With Error)#
Suppose your settings.json looks like this (note the missing comma after line 2):
{
"editor.fontSize": 14,
"editor.wordWrap": "on" // Missing comma here!
"files.autoSave": "afterDelay" // Error: JSONC 514: Expected comma
} VS Code will underline "files.autoSave": "afterDelay" with a red squiggly line, and the Problems panel will point to Line 4 (or wherever the missing comma causes a break).
Fix: Add the Missing Comma#
Insert a comma after the property that precedes the error. In the example above, add a comma after "editor.wordWrap": "on":
{
"editor.fontSize": 14,
"editor.wordWrap": "on", // Comma added here
"files.autoSave": "afterDelay"
} What If There Are Multiple Errors?#
If the Problems panel shows multiple errors (e.g., “Expected comma” and “Unexpected token”):
- Start with the first error listed (errors later in the file often cascade from earlier ones).
- Check the line above the error for missing commas, typos (e.g., missing quotes), or invalid characters (e.g., extra brackets).
Step 4: Save and Verify the Fix#
- Save the
settings.jsonfile by pressingCtrl+S(Windows/Linux) orCmd+S(Mac). - Check the bottom status bar: If the error message (“Unable to write…”) disappears, the fix worked!
- If the error persists, recheck for other syntax issues (e.g., trailing commas after the last property—JSONC does not allow these).
Preventing Future Errors#
To avoid “Expected comma” (and other JSON syntax errors) in settings.json, follow these tips:
1. Use the Settings UI (Instead of Manual JSON Editing)#
The easiest way to avoid JSON syntax errors is to use VS Code’s Settings UI (not the raw JSON file). The UI automatically handles commas and syntax for you:
- Open the Settings UI with
Ctrl+,/Cmd+,. - Search for settings (e.g., “font size”) and toggle/type values directly in the UI.
- Changes are saved to
settings.jsonautomatically—no need to edit JSON manually!
2. Leverage VS Code’s Built-In JSON Validation#
VS Code’s editor underlines invalid JSON in red, and the Problems panel (Ctrl+Shift+M) lists all errors with line numbers. Always check these before saving!
3. Format the File to Spot Issues#
Formatting settings.json makes syntax errors easier to spot:
- Press
Shift+Alt+F(Windows/Linux) orShift+Option+F(Mac) to auto-format the file. - This indents properties consistently, making missing commas or mismatched brackets obvious.
4. Avoid Trailing Commas#
JSON (and JSONC) does not allow commas after the last property in an object. For example:
{
"editor.fontSize": 14,
"editor.theme": "Dark+", // ❌ Trailing comma (invalid!)
} VS Code will flag this as an error. Remove the comma after the last property.
5. Use JSON Linter Extensions#
Extensions like JSON Tools or JSON Validator add extra validation and formatting tools to catch errors early.
Conclusion#
The “JSONC 514: Expected comma” error in VS Code is a common but easily fixable syntax issue. It occurs when you forget a comma between properties in settings.json. By locating the missing comma (using VS Code’s error highlighting), adding it, and saving the file, you’ll resolve the error in minutes.
To prevent future issues, use the Settings UI for edits, rely on VS Code’s built-in JSON validation, and format your file regularly. With these steps, you’ll keep your settings.json clean and error-free!
References#
- VS Code Official Docs: User and Workspace Settings
- JSONC Specification (JSON with Comments)
- JSONLint: Online JSON Validator (for validating JSON syntax outside VS Code)