</>
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

Hostinger Fast & Affordable Web Hosting

Deploy clean, validated JSON APIs on reliable hosting.

Get 80% Off Hosting →

Related JSON Errors

View all JSON errors