Coding⏱️ 3 min read📅 2026-06-03

How to Fix: In VS Code, disable error "Comments are not permitted in JSON"

Disable JSON comments error in VS Code

Quick Answer: Add the following configuration to your VS Code settings: "json.validateComments": false

In VS Code, you may encounter an error message stating that comments are not permitted in JSON files. This issue is primarily related to how VS Code interprets and validates JSON syntax.

The reason behind this error lies in the fact that JSON (JavaScript Object Notation) does not support comments. However, many JSON editors, including VS Code, may display an error message if they detect any non-standard characters or syntax that could be mistaken for a comment.

🛑 Root Causes of the Error

  • The primary cause of this issue is the way VS Code's JSON validation works. When you open a JSON file in VS Code, it checks for valid JSON syntax and may flag comments as errors if they are not properly formatted.
  • Another possible reason could be related to your editor settings or extensions that may interfere with JSON validation.

✅ Best Solutions to Fix It

Disabling Error Messages in VS Code

  1. Step 1: Open the Command Palette in VS Code by pressing `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac). Type 'JSON: Validate Document' and select it from the dropdown list.
  2. Step 2: This will open the JSON validation panel, which allows you to edit your document directly within the editor. You can also use this panel to add or remove comments as needed.
  3. Step 3: Alternatively, you can disable error messages for specific files by adding a configuration setting to your settings.json file. Open the Command Palette and type 'Preferences: Open Settings (JSON)' and select it from the dropdown list.

Alternative Fix Methods

  1. Step 1: If you need to add comments to your JSON files, consider using a different editor that supports comments in JSON syntax. Some popular alternatives include Sublime Text or Atom.
  2. Step 2: Another option is to use a tool like jsonlint or json-correct to validate and format your JSON files before opening them in VS Code.

🎯 Final Words

By following these steps, you should be able to disable the error message about comments not being permitted in JSON files in VS Code. Remember that while comments are not supported in standard JSON syntax, there are alternative solutions available for adding notes or documentation to your JSON files.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions