JSON5
JSON5 is a superset of JSON that allows single quotes, unquoted keys, comments, trailing commas, NaN/Infinity, and hexadecimal numbers, making it better for hand-edited configuration.
Purpose
To relax JSON syntax restrictions so configuration files are easier to write and maintain by hand.
Mechanism
On top of JSON it allows: unquoted keys, single-quoted strings, trailing commas, comments, hexadecimal numbers, NaN/Infinity/-0, and multiline strings. It parses into standard JSON values.
Use cases
- JavaScript configuration files
- Hand-edited configuration
- Prototype data
- An alternative to JSON configuration
Examples
- Input
{name:'Ada',age:36,}OutputThe object {name:"Ada", age:36}Single quotes plus a trailing comma
Common errors
- Parsing JSON5 as standard JSON fails
- Use a dedicated JSON5 parser
Related terms
JSON
JSON (JavaScript Object Notation) is a lightweight data interchange format based on JavaScript object literals, using key-value pairs and arrays. GLOSSARY
HJSON
HJSON (Human JSON) is a human-oriented JSON format that allows comments, unquoted keys and values, multiline strings, and trailing commas, emphasizing readability. GLOSSARY
JSONC
JSONC (JSON with Comments) is a JSON variant that allows comments, used mainly for VS Code configuration (tsconfig, settings.json). GLOSSARY
Related tools
JSON Formatter
Format, minify, or sort JSON online. Free, private, and 100% client-side. TOOL
Json5 Format
Json5 Format — pure client-side tool. Privacy-first, no server round-trip. TOOL
Json5 Validate
Json5 Validate — pure client-side tool. Privacy-first, no server round-trip. TOOL
JSON5 Parser
JSON5 Parser — pure client-side tool. Privacy-first, no server round-trip. TOOL
JSON5 Stringify
JSON5 Stringify — pure client-side tool. Privacy-first, no server round-trip. TOOL