JSON vs JSON5 vs JSONC

Standard JSON allows no comments and no trailing commas; JSON5 adds a broad set of JavaScript-like relaxations; JSONC is a narrower, JSON-compatible superset — mainly used by editor/tooling configs — that only adds comments and trailing commas.

Updated: 2026-08-11

What each format actually allows

JSON (RFC 8259) is strict: double-quoted keys and strings only, no comments, no trailing commas, no unquoted numbers with leading zeros.

JSON5 is a superset aimed at hand-written config: it allows // and /* */ comments, trailing commas, unquoted or single-quoted keys, single-quoted strings, leading/trailing decimal points, and hex numbers.

JSONC keeps JSON's data model unchanged and only adds // and /* */ comments plus trailing commas — it does not add JSON5's quoting or number relaxations.

Where you'll see each one

Plain JSON: API payloads, package.json, and anything consumed by a strict JSON.parse.

JSONC: VS Code's settings.json, tsconfig.json, and other tool configs that want comments without adopting full JSON5.

JSON5: some JavaScript-ecosystem config files that explicitly opt into a JSON5 parser.

The same document in each format

text
// JSON — invalid, comments not allowed
{"name": "birdor", "port": 8080}

// JSONC — valid
{
  // service port
  "name": "birdor",
  "port": 8080, // trailing comma OK
}

// JSON5 — valid, unquoted keys too
{
  name: 'birdor', // single quotes OK
  port: 8080,
}

Parsing them safely

JSON.parse() only accepts strict JSON — feeding it a JSONC or JSON5 document throws a SyntaxError at the first comment or trailing comma.

Reach for a dedicated JSONC- or JSON5-aware parser rather than stripping comments with a regex, which breaks on comment-like text inside string values.

Engineering Notes

i
tsconfig.json and VS Code's settings.json are JSONC, not JSON5 — unquoted keys will fail there even though comments work.
i
When designing a new config format, JSONC is usually the safer default: it's a strict superset of JSON's data model, so a strict-JSON tool that strips comments first can still read it.

Related Concepts

JSON

Related Tools

Related Reference