</>
ValidateHTML

Comments in JSON

JSON does not support any form of comments. Neither // single-line comments nor /* multi-line comments */ are valid. This was a deliberate design choice by Douglas Crockford to keep JSON simple and prevent abuse of comments for parsing directives.

Why It Matters

Adding comments to JSON makes it unparseable by any standard JSON parser. This is a common issue with configuration files where developers want to document settings inline.

Code Examples

Invalid JSON
{
  // This is the user's name
  "name": "John",
  /* Age in years */
  "age": 30,
  "active": true // currently active
}
Valid JSON
{
  "name": "John",
  "age": 30,
  "active": true,
  "_comment_active": "Whether the user is currently active"
}

How to Fix

  • 1Remove all // and /* */ comments from your JSON files.
  • 2Use a _comment or __note key if you need inline documentation.
  • 3Consider using JSONC (JSON with Comments) format for config files. VS Code and TypeScript support it.
  • 4For configuration files, consider YAML or TOML which natively support comments.

Check Your JSON Now

Our JSON validator detects this error automatically and shows the exact line and column.

Open JSON Validator
Recommended

Cloudways · Managed Cloud Hosting

Fix this JSON error, then deploy on Cloudways managed cloud (AWS, GCP, DigitalOcean). 20% off 3 months with code VALIDATEHTML.

Start free trial

Related JSON Errors

View all JSON errors