JSONC and JSON5 versus strict JSON
Plain JSON is deliberately minimal: no comments, no trailing commas, double quotes only. Two supersets relax those rules for human-edited config files. JSONC adds just comments and trailing commas. JSON5 goes much further, borrowing many JavaScript object-literal conveniences. This reference compares each feature across all three.
How it works
Both supersets are parsed by dedicated tools, never by JSON.parse. JSONC
tolerates comments and trailing commas; JSON5 additionally accepts unquoted
keys, single quotes and more:
{
// JSONC and JSON5: a comment
key: 'value', // JSON5 only: unquoted key + single quotes
hex: 0xFF, // JSON5 only: hexadecimal
list: [1, 2, 3,], // trailing comma in both supersets
}
To consume these formats in a strict-JSON pipeline you either run them through a JSON5/JSONC parser or pre-strip the extensions back to canonical JSON.
Tips and notes
- VS Code config files (
tsconfig.json,settings.json) are JSONC, not JSON. - A trailing comma is the single most common reason
JSON.parserejects a config file. - Reach for JSON5 when humans edit the file often; keep machine-to-machine APIs on strict JSON.
- After editing, validate with the right parser so an unquoted key or stray comment is caught early.