JSON6 JSON for the ES6 Era

JSON6 is JSON5 plus back-tick strings, numeric separators, binary and octal numbers, and more. The complete, tested reference for the format and its parser.

Every valid JSON document is valid JSON6. Reference parser: json-6 on npm, MIT licensed.

What is JSON6?

JSON6 is a data format created by d3x0r that extends JSON with syntax borrowed from ECMAScript so that people can write and maintain data by hand. It includes every feature of JSON5 (comments, trailing commas, unquoted keys, single-quoted strings, hexadecimal numbers, Infinity and NaN) and adds a short list of its own: back-tick strings, multi-line strings in every quote style, \u{...} escapes, underscore digit separators, 0b binary and 0o octal numbers, leading-zero decimals, the undefined keyword and empty array members.

It adds no new data types. A JSON6 document still describes objects, arrays, strings, numbers, booleans and null, so anything a JSON6 parser returns can be serialized back to plain JSON, with the usual caveats for undefined, NaN and Infinity. Files use the .json6 extension because, as the project itself says, JSON6 content may not work with existing JSON parsers.

Not an official successor to JSON. JSON6 is a proposal and a reference implementation from one author, not an ECMA or IETF standard. This site is independent and is not the project's own documentation; the project lives at github.com/d3x0r/JSON6.

What JSON6 Adds

The JSON5 baseline plus the extensions that make JSON6 its own format.

Back-tick Strings

Use the grave accent as a third quote style, for values and for keys. There is no template substitution; ${x} stays as literal text.

`text`

Real Multi-line Strings

Single, double and back-tick strings may all span lines, and the newlines are kept. A trailing backslash removes the line break.

'a
b'

Numeric Separators

Group digits with underscores in decimal, hex, binary and octal numbers so large constants stay readable.

123_456_789

Binary and Octal

Write flags and permissions in the base that fits, with 0b and 0o prefixes next to the 0x hex that JSON5 already allows.

0b0110, 0o755

Empty Array Members

A run of commas produces holes in the array, exactly like a JavaScript array literal. Stringify keeps the holes.

[1,,3]

undefined and Leniency

The undefined keyword, leading-zero decimals, repeated signs and extra whitespace characters are all accepted, with opt-in strict switches.

undefined, 0042

Quick Example

// service.json6 - parsed with JSON6.parse() { name: 'billing-service', port: 0x1F90, // 8080 in hex maxBytes: 64_000_000, // digit separators fileMode: 0o644, // octal flags: 0b0000_1011, // binary motd: `Welcome. Maintenance runs at 02:00 UTC.`, // newline is kept fallback: undefined, slots: [1, , 3], // hole at index 1 'content-type': "application/json", }

This example also happens to be a valid JavaScript object literal, but that is not guaranteed for every JSON6 file (leading-zero decimals and repeated signs are not). To hold a file to the JavaScript subset, enable the parser's esStrictCompatible option; see the spec overview.

JSON vs JSON5 vs JSON6

JSON6 is a strict step up from JSON5 in what it accepts. The full matrix, including JSOX, YAML and TOML, is on the comparison page.

Feature JSON JSON5 JSON6
Comments
Trailing commas
Hex, Infinity, NaN
Back-tick strings
Underscore separators
Binary and octal numbers
Empty array members
Streaming parser

Where JSON6 Fits

JSON6 suits files that people edit and programs read. It is a poor fit where interoperability is the point.

Config Files

Commented settings loaded once at startup

Test Fixtures

Readable data with multi-line text blocks

Bit-level Data

Flags and masks in binary, octal and hex

Streams

Back-to-back values parsed as they arrive

Small ecosystem. JSON6 has one maintained parser, json-6, and no editor extensions or language ports that we could verify. Read Why JSON6 before you commit to it for anything that other teams or tools must read.

Ready to Learn More?

Read the case for JSON6, check the cheat sheet, or jump to the guides for Node.js, TypeScript and the browser.