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
{
// This is the user's name
"name": "John",
/* Age in years */
"age": 30,
"active": true // currently active
}{
"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 ValidatorHostinger — Fast & Affordable Web Hosting
Deploy clean, validated JSON APIs on reliable hosting.
Related JSON Errors
Unexpected Token in JSON
Learn why JSON throws an unexpected token error and how to fix it. Common causes include trailing commas, single quotes, and unquoted keys.
Single Quotes in JSON
JSON requires double quotes for all strings and keys. Learn how to fix the single quotes error.
Trailing Comma in JSON
How to fix the trailing comma error in JSON. Unlike JavaScript, JSON does not allow a comma after the last element.