Enable JSON with Comments in VS Code

Enable JSON with Comments in VS Code

JSON doesn't support comments by default but some parsers and apps allow you to add comments especially that JSON is nowadays used for configuration files where comments can be very useful.

If you use Visual Studio Code IDE, comments can't be added to JSON files by default but you can enable them by setting JSONC (JSON with Comments) as the parser in VS Code.

If you edit a JSON file that contains comments. VS Code will outputs an error saying: "Comments are not permitted in JSON."

Let's see how to enable JSON comments.

Setting JSON with Comments In VS Code

Click on JSON at the bottom-right corner then type jsonc to use the JSON with Comments file association.

You can also configure JSONC for all JSON files by adding the following settings:

"files.associations": {
    "<specific file>.json": "jsonc"
}
"files.associations": {
    "*.json": "jsonc"
}

✋If you have any questions about this article, ask them in our GitHub Discussions 👈 community. You can also Gitter

✋ Want to master Angular 14? Read our angular tutorial and join our #DailyAngularChallenge where we learn to build components, directives, services, pipes and complete web, mobile, and desktop applications with latest Angular version.

✋ Make sure to join our Angular 14 Dev Community 👈 to discuss anything related to Angular development.

❤️ Like our page and subscribe to our feed for updates!