JSON Toolkit

JSON vs JSON5 vs JSONC

Bottom line: Strict supersets in order: JSONC adds comments; JSON5 adds single quotes, unquoted keys, trailing commas and hex numbers. Choosing wrong breaks an API, not your editor.

Beginner~4 min readPublished 2026-10-30Updated 2026-10-30
Feature comparison of JSON, JSON5 and JSONC

Bottom line: use standard JSON whenever data crosses a system boundary, and use JSONC only for local config that humans edit; reach for JSON5 when you need single quotes, trailing commas or unquoted keys, but confirm the loader supports it first.

In one line: JSONC is JSON plus comments; JSON5 is JSON plus JavaScript habits.

Feature matrix

Feature JSON JSONC JSON5
Double-quoted strings ✅ ✅ ✅
Single-quoted strings ❌ ❌ ✅
Unquoted keys ❌ ❌ ✅
// line comments ❌ ✅ ✅
/* */ block comments ❌ ✅ ✅
Trailing commas ❌ ❌ ✅
Hex numbers 0xFF ❌ ❌ ✅
Infinity / NaN ❌ ❌ ✅
Multi-line strings ❌ ❌ ✅
Readable by standard parsers ✅ ❌ ❌

Note that JSONC solves comments only. Many people assume "JSON that allows comments" also allows trailing commas; tsconfig.json still fails on one.

What each is for

JSON — interchange. APIs, queues, database JSON columns, logs. Anything machine-to-machine.

JSONC — editor configuration. VS Code parses these files itself, so JSON.parse never sees them. There is no RFC; it is a Microsoft-led de facto convention.

JSON5 — a lenient superset for humans. The goal was "config that looks like a JavaScript object literal". Best suited to .json5 files loaded by build tools; the broadest syntax and the narrowest tooling support.

Choosing

Situation Pick
Request or response bodies JSON, no alternative
JSON columns in MySQL / PostgreSQL JSON, their functions accept nothing else
Project config that needs explanation JSONC if supported, otherwise YAML
You want JS-style looseness JSON5, after confirming the loader supports it
Non-engineers will edit it YAML, indentation beats braces

One easy trap

Parsing a JSONC file as strict JSON produces an error that points at the comment:

SyntaxError: Unexpected token / in JSON at position 42

Before deleting the comment, check whether the file is meant to be JSONC. Delete it and you may still hit a trailing comma two lines later.

FAQ

How should I choose between JSONC and JSON5?

Use JSONC when comments are the only thing you need: it adds // and /* */ on top of JSON, and VS Code's settings.json and tsconfig.json use it. Use JSON5 when you also want single quotes, unquoted keys, trailing commas, hex numbers or multi-line strings. Both depend on the loader, so confirm the tool that reads the file supports it.

Why can't a JSONC file be read as standard JSON?

JSONC is a de facto convention, not a separate RFC, so standard parsers reject comments. JSON.parse on such a file throws Unexpected token /, pointing at the comment rather than the data. Only configuration read by an editor or a dedicated parser should be written as JSONC.

Should I send a JSON5 file to an API?

No. APIs, database JSON columns and queues parse strict JSON, so JSON5's single quotes, unquoted keys and trailing commas are rejected. JSON5 is for local configuration humans edit; convert it to standard JSON before it crosses a system boundary.

Further reading