Frequently Asked Questions
Answers about JSON6 syntax, the json-6 parser, compatibility and where it fits.
FAQ
JSON6 is a data format and reference parser by d3x0r that extends JSON with syntax borrowed from ECMAScript so people can write data by hand. It includes every JSON5 feature and adds back-tick strings, multi-line strings in all quote styles, \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.
In one direction. Any valid JSON document parses with JSON6.parse(), so you can start by renaming a file to .json6. The other direction fails: a JSON6 document with comments, unquoted keys or any other extension will not parse with JSON.parse(). That is why the project uses its own .json6 extension.
JSON6 accepts everything JSON5 does and more. The additions are back-tick strings and keys, raw line breaks inside any string, \u{...} code point escapes, _ digit separators, 0b and 0o numbers, decimals with leading zeros, repeated leading signs, undefined, empty array members, and extra whitespace characters. JSON6 also has a streaming reader. The JSON5 differences page lists each one with examples.
No. The project calls JSON6 a proposed extension to JSON and says it is not an official successor. There is no ECMA or IETF specification for it; the README and the reference parser define the format. Its sibling format JSOX does have an IETF Internet-Draft, but a draft is not a standard either.
Run npm install json-6. The npm package is named json-6 (with a hyphen) and the library exposes a JSON6 object. It is MIT licensed, has no runtime dependencies and ships TypeScript declarations. See Getting Started.
Require the package and call JSON6.parse(), which mirrors JSON.parse() and accepts an optional reviver and an options object: const JSON6 = require('json-6'); const cfg = JSON6.parse(text);. Read the Node.js guide for file loading and error handling.
Yes. For CommonJS, run require('json-6/lib/require') once and then require('./app.json6'). For ES modules on Node 20.6 or newer start your program with node --import json-6/lib/register.mjs app.mjs; older versions can use --experimental-loader json-6/lib/import.mjs.
Yes. The README shows loading node_modules/json-6/lib/json6.js with a script tag, which adds a global JSON6 object, and the package declares a browser bundle at dist/index.js that bundlers pick up. Native browsers parse only JSON, so you do need the library. See the browser guide.
Yes. Declarations are generated from JSDoc and shipped in the package dist/ folder since version 1.1.5, and version 1.1.6 fixed a declaration file that TypeScript 5 rejected without skipLibCheck. Use 1.1.6 or later. The TypeScript guide has the details.
We could not find a dedicated JSON6 editor extension, so we do not list one. The practical workaround is to associate *.json6 with JSON5 or JavaScript highlighting, which covers most of the syntax; back-tick keys and numeric separators may look unusual. The editors page shows how.
None that we could verify. The README mentions only the JavaScript parser and the sack.vfs native Node.js addon by the same author. If you need a cross-language format, JSON5 is a better fit, and plain JSON is the safest.
A number with a leading zero followed by more digits is decimal. The README argues that every text-to-number routine, such as Number("0123"), reads it that way and that legacy octal is a source-code lexer convention. If you want octal, write 0o123. The opt-in esStrictCompatible option rejects leading-zero numbers instead, matching ECMAScript strict mode.
No. npm requires standard JSON. The json-6 project keeps a package.json6 and generates package.json from it with npm run build, a pattern you can copy.
Parse with JSON6.parse() and serialize with JSON.stringify(value, null, 2). For files, the bundled command line tool does it: npx json-6 -c file.json6 writes file.json next to it with four-space indentation. The README names the executable json6, but npm installs it as json-6.
Comments disappear, because they are not data. Holes in arrays and undefined values become null in arrays and are omitted from objects when passed through JSON.stringify, and NaN and Infinity become null. Numbers keep their value but lose their original base and separators.
No, it produces JSON6. Keys that are valid identifiers are written bare and sorted alphabetically by default, string values are double-quoted, and NaN and Infinity are written as is. Use JSON.stringify when a JSON-only consumer will read the output, or pass { sortKeys: false } to keep your key order.
Not in version 1.1.7. JSON6.parse('{a:1} junk') returns { a: 1 }, because the parser returns once the first complete value is read. If you need whole-document validation, use JSON6.begin() and count the values, or check the input length yourself.
There are four, all off by default: esStrictCompatible narrows the grammar to a subset of ECMAScript strict mode, forbidTemplateSubstitution rejects ${ in back-tick strings, normalizeNumericKeys turns a key like 1e3 into "1000", and warnWithCommentWithoutEOL logs a warning for a line comment that ends the document without a line break.
JSON6 is data, and JSON6.parse() does not execute code, but it is more permissive than JSON, so validate the resulting value as you would any input. If the text may later be evaluated as JavaScript, turn on forbidTemplateSubstitution or esStrictCompatible, and never use eval() to read JSON6.
JSOX is the same author's later format. It builds on JSON6 and adds dates, big integers, typed arrays, maps and cyclic references, and it has an IETF Internet-Draft (draft-buckeyne-jsox-format). Choose JSOX when you need those types and JSON6 when you do not. See resources for links.
Yes. Version 1.1.4 was published in 2021 and versions 1.1.5, 1.1.6 and 1.1.7 followed in October 2026 with TypeScript declarations, an options argument, many parser and stringify fixes and a new ESM loader. It is a single-author project, so pin your version and read the changelog before upgrading.
Still Have Questions?
Ask us, or open an issue on the project repository for questions about the parser itself.