Saltar al contenido
uencoder

Especificación JSON5

JSON5 es un superset de JSON enabling comments, trailing commas, unquoted claves, y más relaxed syntax.

Syntax Extensions

JSON5 allows single and multi-line comments using // and /* */ syntax. Object keys may be unquoted if they are valid identifiers. Strings can use single quotes in addition to double quotes. Trailing commas in arrays and objects are permitted. Numbers support hexadecimal notation, leading/trailing decimal points, and positive/negative infinity.

comments
Single and multi-line
// line /* block */
unquoted keys
Valid identifiers
{ key: 1 }
hex numbers
Hexadecimal notation
0xFF

Compatibility and Parsing

Every valid JSON document is also valid JSON5, ensuring backward compatibility. JSON5 parsers are available for JavaScript, Python, and other languages. The format is primarily intended for human-edited configuration files, not data interchange. JSON5 is not an official standard but is widely adopted in tooling. For machine-to-machine exchange, standard JSON remains preferred.

superset
Valid JSON is valid JSON5
backward compatible
use case
Config files, not interchange
human-edited
parsers
Available in many languages
npm: json5

Herramientas relacionadas

参考链接