Skip to main content
Developer & Security 7 min read

JSON vs JSONC vs JSON5: Differences and When to Use Each

Standard JSON is strict — no comments, no trailing commas, keys must be quoted. JSONC and JSON5 relax these rules. Here is when each format is the right choice.

MD
Meet Dhameliya

You open a project's tsconfig.json and see comments inside a JSON file. You add a trailing comma to your package.json and the build fails. You try to explain a config value with a comment and realize JSON does not allow comments. Welcome to the confusing world of JSON variants.

Standard JSON (RFC 8259)

JSON (JavaScript Object Notation) is the universal data interchange format. It is intentionally strict:

Use standard JSON when: Data is exchanged between systems (APIs, databases, configuration files read by strict parsers).

JSONC — JSON with Comments

JSONC (JSON with Comments) is not an official standard — it is a convention used by VS Code, TypeScript, and other tools. It extends JSON with exactly two additions:

Files that use JSONC include tsconfig.json, .vscode/settings.json, and devcontainer.json. These files have a .json extension but are parsed by JSONC-aware parsers.

Important: Standard JSON.parse() in JavaScript will reject JSONC. You need a JSONC parser like jsonc-parser or the VS Code JSON module.

JSON5 — The Human-Friendly Version

JSON5 extends JSON significantly to make it more comfortable for humans to write:

Use JSON5 when: Configuration files that humans edit frequently (like build tool configs). The json5 npm package provides parsing.

Quick Comparison

FeatureJSONJSONCJSON5
Comments
Trailing commas
Unquoted keys
Single-quoted strings
Multiline strings
Native browser parsing
API data interchange

Which One Should You Use?

For APIs and data exchange: Always use standard JSON. It is universally supported and every language has a built-in parser.

For TypeScript/VS Code config: Use JSONC — it is what these tools expect.

For human-authored config files: Consider JSON5 or switch to YAML/TOML, which were designed for human readability.

Need to validate or format your JSON? Our JSON Formatter & Validator checks strict JSON syntax and pinpoints the exact location of errors.

Frequently Asked Questions

Why does JSON not allow comments? expand_more
Douglas Crockford, who standardized JSON, intentionally removed comments. He observed that developers were using comments to embed parsing directives, which created interoperability problems. JSON was designed to be a pure data format, not a configuration language.
Is tsconfig.json actually JSON or JSONC? expand_more
tsconfig.json uses JSONC format — it allows comments and trailing commas. TypeScript's parser handles this automatically. However, if you try to parse tsconfig.json with standard JSON.parse(), it will fail on any comments.
Can I use JSON5 in a web browser? expand_more
Browsers do not natively parse JSON5. You need to include the json5 npm package (about 2 KB minified) in your project. For server-to-client data exchange, use standard JSON which browsers parse natively with JSON.parse().

build Related Tools

MD

Meet Dhameliya

Founder & Product Manager

Computer Engineering graduate with 3+ years in IT. Meet built Utility Spark to create privacy-first browser tools that process your data locally — no uploads, no accounts.