What JSON5 is
JSON5 is a small superset of JSON that adds back the JavaScript-object-literal features Douglas Crockford left out of JSON in 2002. Comments, trailing commas, single quotes, unquoted keys. The JSON5 1.0.0 specification was published in 2018, and the format is stable — no new features expected.
Every valid JSON document is also valid JSON5. The reverse is not true. JSON5 files conventionally use the .json5 extension to signal that strict parsers should not be pointed at them.
What it adds on top of JSON
{
// Single-line comments
/* and block comments */
unquoted: 'key', // identifier keys, single-quoted strings
hexadecimal: 0xdecaf, // 0x integers
leadingDecimal: .8675309, // numbers can start with a dot
trailing: 'comma', // and end with one
positiveSign: +1, // explicit + sign
inf: Infinity, // Infinity, -Infinity, NaN
multiLine: 'line one \
line two', // strings can span lines
}Every one of these features is what JavaScript object literals already allow. JSON5 is essentially "object literal syntax frozen at ES5." If you have ever pasted a JavaScript config into a JSON file and watched it explode, JSON5 is the format that would have accepted it.
Where it actually fits
One use case dominates: hand-edited config files. Build tool configs, project manifests, fixtures with annotations — anywhere a human types the JSON and wants to leave notes.
The most visible adopters: Babel (.babelrc accepts JSON5), Renovate (config files), Wrangler (Cloudflare Workers), Bun (loads .json5 imports natively), Vercel for some configs. The pattern is the same: a config file that ships once and gets read by humans many times.
It is also good for fixtures in test suites where you want explanatory comments next to the data. Production code that exchanges data over the wire should still use strict JSON — every consumer parses it without negotiation.
JSON5 vs JSONC
JSONC ("JSON with Comments") is the format VS Code invented for its own settings files. It is strictly less ambitious than JSON5: it adds only comments and trailing commas, nothing else. tsconfig.json, settings.json, and .vscode/*.json are all JSONC.
When deciding which to use: JSONC is "JSON plus comments," JSON5 is "JSON plus everything ES5 allowed." If your only complaint with strict JSON is the lack of comments, pick JSONC — fewer surprises for tools that try to read your file as plain JSON. If you also want unquoted keys and single quotes, you need JSON5.
Microsoft maintains jsonc-parser as the reference implementation. It is small, dependency-free, and used by every VS Code extension that reads config files.
Libraries and tooling
JavaScript / Node: the official json5 npm package is the reference implementation, around 25 kB minified. Drop-in API: JSON5.parse and JSON5.stringify.
import JSON5 from 'json5';
const config = JSON5.parse(text); // accepts JSON5 features
JSON5.stringify(config, null, 2); // emits valid JSON5
// Strict JSON output (no quotes-as-options, etc.)
JSON.stringify(config, null, 2); // works fine — JSON5 → JSON downconverts losslesslyPython: pyjson5 on PyPI. Go: github.com/titanous/json5. Rust: json5 on crates.io. Quality varies — the JavaScript implementation is the canonical one.
For everyday inspection, the JSON validator on this site rejects JSON5 features by design — it tests strict RFC 8259 conformance. If you want to convert JSON5 to strict JSON, use the repair tool, which strips comments and trailing commas and converts single quotes to double quotes in one pass.
When not to use it
API payloads. Your clients run a strict JSON parser. Adding comments to an API response breaks every consumer.
Database documents. Postgres jsonb, MongoDB BSON, and every JSON-native datastore enforce strict JSON. Comments and trailing commas will be rejected at insert.
Files consumed by mixed tooling. If the same file is read by your build script (which uses JSON5) and your CI runner (which uses strict JSON), one of the two will break. Pick one format and convert at the boundary.
For everything else — your manually-maintained config, your seed fixtures, your one-off scripts — JSON5 is a small quality-of-life upgrade with a stable spec and good library support. It will not replace JSON. It is a niche, and it fits its niche well.