JSONC
JSONC (JSON with Comments) is a JSON variant that allows comments, used mainly for VS Code configuration (tsconfig, settings.json).
Purpose
To allow comments in JSON so configuration files can carry explanations, improving maintainability.
Mechanism
On top of JSON it allows // single-line and /* */ multiline comments; the rest of the syntax is JSON. VS Code and the TypeScript compiler support it. Some implementations also allow trailing commas.
Use cases
- VS Code settings.json
- tsconfig.json
- ESLint configuration
- IDE configuration files
Examples
- Input
{// comment "a":1}OutputThe object {a:1}Comments are allowed
Common errors
- A standard JSON parser fails on JSONC
- Use a comment-aware parser such as jsonc-parser
Related terms
JSON
JSON (JavaScript Object Notation) is a lightweight data interchange format based on JavaScript object literals, using key-value pairs and arrays. GLOSSARY
JSON5
JSON5 is a superset of JSON that allows single quotes, unquoted keys, comments, trailing commas, NaN/Infinity, and hexadecimal numbers, making it better for hand-edited configuration. GLOSSARY
HJSON
HJSON (Human JSON) is a human-oriented JSON format that allows comments, unquoted keys and values, multiline strings, and trailing commas, emphasizing readability. GLOSSARY
Related tools
JSON Formatter
Format, minify, or sort JSON online. Free, private, and 100% client-side. TOOL
Jsonc Format
Jsonc Format — pure client-side tool. Privacy-first, no server round-trip. TOOL
Jsonc Validate
Jsonc Validate — pure client-side tool. Privacy-first, no server round-trip. TOOL
JSONC Parser
JSONC Parser — pure client-side tool. Privacy-first, no server round-trip. TOOL
JSONC Stringify
JSONC Stringify — pure client-side tool. Privacy-first, no server round-trip. TOOL