# What JSON5 Leaves Out, and Why | The Design Rationale


Source: https://json5.dev/design-rationale/

---

# What JSON5 Leaves Out, and Why

The features people ask for, what the maintainers answered, and what to do instead.

JSON5 adds comments, trailing commas, single quotes and friendlier numbers to JSON, then deliberately stops. Requests for dates, BigInt literals, variables, arithmetic, regular expressions, backtick strings and more were declined or left undecided.

This page collects the record from the library and specification issue trackers going back to 2012, quotes the maintainers with links to their comments, says plainly where no firm ruling exists, and gives a tested workaround for each gap.

![A design review table sorting JSON5 feature cards into a kept tray and a left out tray](https://json5.dev/img/hero/design-rationale.png)

**TL;DR:** JSON5 stays a superset of JSON and valid ECMAScript 5.1, and aims to be minimal. Newer JavaScript syntax is out because of the ES5 rule; variables, math and `undefined` are out for simplicity and portability. Most gaps are filled with strings plus a reviver, a schema, or a source-editing tool.

[Principles](#principles) [Overview](#overview) [Dates](#dates) [BigInt](#bigint) [Binary Data](#binary) [Comments](#comments) [Variables](#variables) [Math](#math) [RegExp](#regexp) [Backticks](#template-strings) [Hex Floats](#hex-floats) [Binary and Octal](#binary-octal) [Separators](#separators) [Array Holes](#holes) [undefined](#undefined) [Multiline](#multiline) [Duplicate Keys](#duplicate-keys) [Unquoted Values](#unquoted-values) [Infinity and NaN](#exception) [FAQ](#faq) [Sources](#references)

![Target icon](https://json5.dev/images/icons/target.png)

## The Design Principles

JSON5 is easiest to understand as three constraints applied at once. Every request on this page ran into at least one of them.

Principle

What it means

What it rules out

Superset of JSON

Every valid JSON text is also valid JSON5

Any new meaning for text JSON already accepts, including turning date-like strings into dates

Valid ECMAScript 5.1

The syntax comes from ES5, one fixed edition

Template literals, `0b` and `0o` numbers, digit separators, BigInt literals

Minimal

A few features that help people write documents by hand

Variables, arithmetic, references between values, anything that behaves like a program

The [superset](https://json5.dev/glossary/#superset) and ES5 rules are in the [specification](https://spec.json5.org/) introduction. The ES5 rule is stated most firmly in the reference library's README:

> "Note that we will never add any features that make JSON5 incompatible with ES5; that compatibility is a fundamental premise of JSON5."
> 
> [json5 README, Issues section](https://github.com/json5/json5#readme)

An [older README](https://github.com/json5/json5/blob/5cbd65659706f4071e7cbf3aebd4298c0a879c2d/README.md), which a maintainer later linked as the home of the rule, added a fourth idea:

> "JSON5 remains a strict subset of JavaScript, adds no new data types, and works with all existing JSON content."
> 
> Earlier json5 README

In 2020 Tucker called it the "unofficially official" no new data types rule ([spec #4](https://github.com/json5/json5-spec/issues/4#issuecomment-625977564)).

Why hold the line so tightly? Jordan Tucker, who wrote the official specification and rewrote the reference library, gave two reasons when declining backtick strings in 2019:

> "Keeping JSON5 compatible with ES5 protects the project from scope creep."
> 
> Jordan Tucker, [spec #16, August 2019](https://github.com/json5/json5-spec/issues/16#issuecomment-518444731)

> "Adding too many features actually makes it harder for humans to use because it expands the scope of features you need to remember when reading or writing JSON5."
> 
> Jordan Tucker, [spec #16, August 2019](https://github.com/json5/json5-spec/issues/16#issuecomment-518444731)

Months earlier, noting that he could not speak for founder Aseem Kishore, he had explained what the fixed target buys users: "JSON5 syntax will never go beyond the syntax of ES5." The cost, he wrote, is missing newer features; the gain is that nobody has to ask which version a library supports ([json5 #190, February 2019](https://github.com/json5/json5/issues/190#issuecomment-459741344)). In the same comment he said he would not mind separately named formats for later syntax. In 2023 he added that the syntax had been formal for over five years, so "adding new syntax would create fragmentation in the ecosystem, essentially creating multiple versions of JSON5" ([json5 #292](https://github.com/json5/json5/issues/292#issuecomment-1779731406)). Open [spec issue 56](https://github.com/json5/json5-spec/issues/56) asks for an upgrade past ES5.1; no change had been adopted at this review.

ES5 compatibility is a ceiling, not a quota. Plenty of valid ES5, such as array holes, `undefined` and arithmetic, is also left out. Those omissions rest on the other two principles.

![Table icon](https://json5.dev/images/icons/table.png)

## Status at a Glance

Status describes the format as of November 29, 2026: specification 1.0.0 and reference library `json5` 2.2.3, the latest npm release. "Declined" means a maintainer closed or refused the request. "Open" means an issue is still collecting discussion, which is not a promise of change.

Feature

Valid JSON5?

Status

Main reason on record

[Date values](#dates)

![No](https://json5.dev/images/icons/no.png)

Declined as syntax; string recommendation open

No new data types

[BigInt literal](#bigint)

![No](https://json5.dev/images/icons/no.png)

No literal; recommendation open

Not ES5; large integers already legal

[Binary data](#binary)

![No](https://json5.dev/images/icons/no.png)

No literal; recommendation open

No new data types

[Comment preservation](#comments)

Comments parse, then are discarded

Not in the reference library

Library kept as a simple reference

[Variables and imports](#variables)

![No](https://json5.dev/images/icons/no.png)

Declined

Scope and ES5

[Math expressions](#math)

![No](https://json5.dev/images/icons/no.png)

Closed

Incompatible with the spec

[RegExp literal](#regexp)

![No](https://json5.dev/images/icons/no.png)

Not in spec; library issue open

Platform-specific, hard to parse

[Backtick strings](#template-strings)

![No](https://json5.dev/images/icons/no.png)

Declined

Not ES5

[Hex floating point](#hex-floats)

![No](https://json5.dev/images/icons/no.png)

Declined

Breaks JavaScript compatibility

[Binary and octal literals](#binary-octal)

![No](https://json5.dev/images/icons/no.png)

Declined

Not ES5; leading zeros confuse

[Numeric separators](#separators)

![No](https://json5.dev/images/icons/no.png)

Declined

Not ES5

[Omitted array elements](#holes)

![No](https://json5.dev/images/icons/no.png)

Declined

Simplicity; no new data types

[undefined](#undefined)

![No](https://json5.dev/images/icons/no.png)

Declined

Specific to JavaScript

[Raw multiline strings](#multiline)

![No](https://json5.dev/images/icons/no.png)

Declined

Not ES5

[Duplicate names](#duplicate-keys)

![Yes](https://json5.dev/images/icons/yes.png)

Allowed, behavior unspecified; issue open

Changing it would break implementations

[Unquoted string values](#unquoted-values)

![No](https://json5.dev/images/icons/no.png)

Declined

ECMAScript has no such thing

Code on this page was run with `json5` 2.2.3 on Node.js 24, and assumes `const JSON5 = require('json5')`. Errors shown are the library's real messages.

![Time icon](https://json5.dev/images/icons/time.png)

## Dates and Times

**Status:** Not in the specification. Discussion of a string recommendation is open in [spec #4](https://github.com/json5/json5-spec/issues/4).

### Recorded reason

Date support was the third issue filed on the library, in May 2012. After weighing ideas such as `new Date(...)` syntax, founder Aseem Kishore gave his first answer a few days later:

> "Let's keep things simple here and stick to the "no new data types" philosophy, and for developer convenience, _this JS implementation_ will add an option to auto-try-parse all strings into JS `Date` objects"
> 
> Aseem Kishore, [json5 #3, June 2012](https://github.com/json5/json5/issues/3#issuecomment-6081814)

That did not end the debate. In 2014 Tucker moved to close the issue, and Kishore kept it open, calling it a "Tough call!" ([comment](https://github.com/json5/json5/issues/3#issuecomment-50978562)). In 2017 Tucker prototyped a library-only `dates` option for `parse` ([comment](https://github.com/json5/json5/issues/3#issuecomment-331679238)). Version 2.2.3 has no such option, and the issue was closed in 2018 as incompatible with the specification. On the specification side he explained why syntax was the wrong place:

> "Adding dates to the _syntax_, something that almost no other programming language or data interchange format has done, adds more complexity than it's worth. Dates are handled just fine by strings and schema."
> 
> Jordan Tucker, [spec #4, November 2019](https://github.com/json5/json5-spec/issues/4#issuecomment-559913441)

He also objected to parsers guessing, writing in 2018 that he was "hesitant to have parsers automatically convert date-like strings to dates" because strings would become "maybe-dates" ([comment](https://github.com/json5/json5-spec/issues/4#issuecomment-373868688)). In 2018 he also drafted a recommendation, on a [v1.1.0 branch of the specification](https://github.com/json5/json5-spec/tree/v1.1.0), that generators write dates as UTC strings in [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339) format, with Unix time as an alternative. It is not part of version 1.0.0. He closed the issue in May 2020 and reopened it five days later, because the original request was only for a recommendation ([comment](https://github.com/json5/json5-spec/issues/4#issuecomment-628203241)). In 2022 he added that it might be wise to recommend that parsers not convert such strings automatically without a data contract or an opt-in or opt-out ([comment](https://github.com/json5/json5-spec/issues/4#issuecomment-1097075885)).

### Workaround

Store an RFC 3339 string and convert only the keys you know are dates. `stringify` calls the built-in `Date.prototype.toJSON`, so writing needs no extra code.

`const ISO = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/; const DATE_KEYS = new Set(['released', 'expires']); const text = "{ released: '2026-01-15T08:30:00Z', note: '2026-01-15T08:30:00Z' }"; const cfg = JSON5.parse(text, (key, value) => { if (!DATE_KEYS.has(key)) return value; if (typeof value !== 'string' || !ISO.test(value)) { throw new TypeError(key + ' must be an RFC 3339 UTC date-time'); } return new Date(value); }); cfg.released instanceof Date; // true typeof cfg.note; // 'string' JSON5.stringify(cfg); // "{released:'2026-01-15T08:30:00.000Z',note:'2026-01-15T08:30:00Z'}"`

The pattern checks shape only. Validate calendar ranges with a schema or a date library if bad input is possible.

![Number icon](https://json5.dev/images/icons/hashtag.png)

## BigInt and Large Integers

**Status:** No `123n` literal. Integers of any size are already legal text. A recommendation is open in [spec #36](https://github.com/json5/json5-spec/issues/36).

### Recorded reason

The first request, [spec #8](https://github.com/json5/json5-spec/issues/8), drew this answer in 2018: because the spec sets no limit on integer length, a long integer is already supported, while the `n` suffix "is a violation of the ES5 spec." Tucker expanded in 2022:

> "Adding a BigInt representation for numbers in JSON5 is not only incompatible with ECMAScript 5, but it would only add the feature of indicating the intended data type of a number."
> 
> Jordan Tucker, [spec #36, May 2022](https://github.com/json5/json5-spec/issues/36#issuecomment-1139787561)

The format describes how a number is written and leaves the in-memory type to the parser. A related library request, [json5 #292](https://github.com/json5/json5/issues/292), asked for exact large integers; Tucker answered in 2022 that he preferred an [opt-in option](https://github.com/json5/json5/issues/292#issuecomment-1267499583) over automatic detection, and the issue was closed as completed on October 24, 2026. The released version 2.2.3 still chooses a double, which silently rounds, and its `stringify` silently drops BigInt values (inside an array they become `null`):

`String(JSON5.parse('{id: 36028797018963969}').id); // '36028797018963970' JSON5.parse('{n: 35n}'); // SyntaxError: invalid character 'n' at 1:7 JSON5.stringify(1n); // undefined JSON5.stringify({ a: 1n, b: 2 }); // '{b:2}' JSON5.stringify([1n]); // '[null]'`

**Coming change, unreleased at this review:** the library's [main branch changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) lists an opt-in `parse` option, `{bigint: true}`, that returns integer literals outside the safe integer range as BigInts, and makes `stringify` throw on a BigInt. Neither is in 2.2.3, and neither changes the document syntax.

### Workaround

With the released library, put large integers in strings and convert named keys:

`const BIG_KEYS = new Set(['id']); const reviver = (k, v) => (BIG_KEYS.has(k) ? BigInt(v) : v); const replacer = (k, v) => (typeof v === 'bigint' ? v.toString() : v); const obj = JSON5.parse("{ id: '36028797018963969' }", reviver); obj.id; // 36028797018963969n JSON5.stringify(obj, replacer); // "{id:'36028797018963969'}"`

![Data icon](https://json5.dev/images/icons/database.png)

## Binary Data

**Status:** No binary literal or binary type. Recommending an encoding is open in [spec #35](https://github.com/json5/json5-spec/issues/35).

### Recorded reason

A 2017 proposal for `$deadbeef` literals was declined in one sentence:

> "This conflicts with our goal of having JSON5 be a strict subset of ES5 that adds no new data types."
> 
> Jordan Tucker, [json5 #148, June 2017](https://github.com/json5/json5/issues/148#issuecomment-307641881)

In 2022 he confirmed there were "no plans to include support for a Base64 literal value in JSON5" ([spec #20](https://github.com/json5/json5-spec/issues/20#issuecomment-1140379903)), and in the open issue wrote: "I prefer to use Base64 to encode binary in JSON and JSON5." ([comment](https://github.com/json5/json5-spec/issues/35#issuecomment-1098352956)). That is a stated preference, not specification text. Data URLs and arrays of byte values were also discussed. On data URLs he pointed out that one with no [media type](https://json5.dev/glossary/#media-type) means plain ASCII text, so arbitrary bytes should be labeled `application/octet-stream` ([comment](https://github.com/json5/json5-spec/issues/35#issuecomment-1223551330)). The recommendation issue is assigned to the specification's open v1.1.0 milestone, as is the one on dates. A binary encoding of JSON5 itself was a separate idea, closed in [json5 #186](https://github.com/json5/json5/issues/186) after Tucker asked what it would add over converting to an existing binary format.

### Workaround

`const bytes = Buffer.from('foobar'); const text = JSON5.stringify({ filename: 'a.bin', encoding: 'base64', content: bytes.toString('base64'), }); // "{filename:'a.bin',encoding:'base64',content:'Zm9vYmFy'}" Buffer.from(JSON5.parse(text).content, 'base64').equals(bytes); // true`

Name the encoding in a field or in your schema so readers do not have to guess. For large files, store a path or URL and keep the bytes outside the document.

![Comment icon](https://json5.dev/images/icons/comment.png)

## Preserving Comments

**Status:** Comments are part of the syntax. Keeping them through a parse and rewrite is not offered by the reference library.

### Recorded reason

The specification's lexical grammar discards comments and [white space](https://json5.dev/glossary/#white-space); they never reach the parsed value. Kishore noted in 2016 that rewriting a hand-written file faithfully is impossible "as long as comments are stripped, which `JSON5.parse` does" ([json5 #112](https://github.com/json5/json5/issues/112#issuecomment-196376914)). When asked for a preserving mode in [json5 #177](https://github.com/json5/json5/issues/177), Tucker replied:

> "In an effort to keep JSON5 simple, this library will be a reference parser rather than a full-featured, production-ready implementation of a JSON5 parser."
> 
> Jordan Tucker, [json5 #177, April 2020](https://github.com/json5/json5/issues/177#issuecomment-620348850)

This is a decision about one library, not about the format. In 2022 he mentioned work on a parser class that could output a syntax tree with comments ([json5 #201](https://github.com/json5/json5/issues/201#issuecomment-1279900308)); neither 2.2.3 nor the unreleased changelog lists it. [Round trip](https://json5.dev/glossary/#round-trip) through the released library and the comments are gone:

`const v = JSON5.parse('{\n // keep me\n a: 0x10,\n}'); JSON5.stringify(v, null, 2); // { // a: 16, // }`

### Workaround

Use a tool that edits the source text. [golden-fleece](https://github.com/Rich-Harris/golden-fleece) 1.0.9 patches changed values into the original string:

`const fleece = require('golden-fleece'); const source = "{\n // keep in sync with the load balancer\n port: 8080,\n host: 'localhost', /* dev only */\n}"; const value = fleece.evaluate(source); value.port = 9090; console.log(fleece.patch(source, value)); // { // // keep in sync with the load balancer // port: 9090, // host: 'localhost', /* dev only */ // }`

Its latest release dates from June 2018, and it does not cover the whole format: in our test, 1.0.9 failed on `-NaN`, `+NaN` and on unquoted names that contain non-ASCII letters or `\u` escapes. Test it against your files first. Other options that document comment preservation are [@croct/json5-parser](https://github.com/croct-tech/json5-parser-js) (Node.js), [json-five](https://github.com/spyoungtech/json-five) (Python, model-based load and dump) and [json5format](https://github.com/google/json5format) (a Rust formatter). We did not run those three for this page.

![Link icon](https://json5.dev/images/icons/link.png)

## Variables, References and Imports

**Status:** Declined: constants ([json5 #112](https://github.com/json5/json5/issues/112)), identifier references ([spec #26](https://github.com/json5/json5-spec/issues/26)) and self-references ([spec #32](https://github.com/json5/json5-spec/issues/32)). An import proposal ([spec #7](https://github.com/json5/json5-spec/issues/7)) is closed.

### Recorded reason

Kishore's objection in 2016 was about the shape of the format:

> "There's something elegant about an entire JSON(5) document being a single expression."
> 
> Aseem Kishore, [json5 #112, March 2016](https://github.com/json5/json5/issues/112#issuecomment-196372944)

> "I just feel part of my (limited) role is to be a steward for keeping this project tightly scoped."
> 
> Aseem Kishore, [json5 #112, March 2016](https://github.com/json5/json5/issues/112#issuecomment-196374335)

Tucker agreed in the same thread. Closing the self-reference request in 2024, he called it a very interesting suggestion, said that simplicity is what makes JSON easy to use and implement, and continued:

> "It's already significantly more complex than JSON, so adding this feature is against the core principles of JSON5."
> 
> Jordan Tucker, [spec #32, March 2024](https://github.com/json5/json5-spec/issues/32#issuecomment-1986919939)

For `import`, he did not refuse outright. His 2018 reply listed unsettled questions about syntax, merge order, path resolution, security and cycles ([spec #7](https://github.com/json5/json5-spec/issues/7#issuecomment-422250683)). He closed the issue in May 2020 without a further comment, so no firm ruling is recorded there. A library-level `@` include was declined as breaking ES5 compatibility ([json5 pull 120](https://github.com/json5/json5/issues/120#issuecomment-330986123)).

### Workaround

Resolve placeholders in your own code after parsing, where you control the rules:

`const text = "{\n vars: { host: 'db.internal' },\n primary: 'postgres://{host}/app',\n replica: 'postgres://{host}/app_ro',\n}"; const { vars, ...rest } = JSON5.parse(text); const expand = (s) => s.replace(/\{(\w+)\}/g, (m, name) => { if (!Object.hasOwn(vars, name)) throw new Error('Unknown variable ' + name); return vars[name]; }); const out = JSON.parse(JSON.stringify(rest), (k, v) => (typeof v === 'string' ? expand(v) : v)); // { primary: 'postgres://db.internal/app', replica: 'postgres://db.internal/app_ro' }`

The JSON copy is only a convenient deep walk; it would turn `Infinity` and `NaN` into `null`, so write your own walker if your data uses them. If you need real logic, generate the document from a program.

![Settings icon](https://json5.dev/images/icons/settings.png)

## Math Expressions

**Status:** Not in the format. The request ([json5 #106](https://github.com/json5/json5/issues/106)) and an implementation ([pull 111](https://github.com/json5/json5/pull/111)) were closed in 2018.

### Recorded reason

This one was close. In 2016 Tucker said he had often written expressions like `24*60*60*1000`, and Kishore wrote that he would be "okay with adding basic math operators" ([comment](https://github.com/json5/json5/issues/106#issuecomment-196371989)). Kishore also saw the cost:

> "Even with these basic operators, though, it does e.g. make supporting JSON5 in other languages harder."
> 
> Aseem Kishore, [json5 #106, March 2016](https://github.com/json5/json5/issues/106#issuecomment-196379851)

His example was `5 / 0`, which ES5 evaluates to `Infinity` while, he said, most languages would raise a runtime error. Tucker narrowed that claim to integer division, naming Python and Go as exceptions for floating point, and later supplied the general argument: "The more complex you make a specification, the more work that needs to be done to implement it, and the less it actually gets implemented." ([comment](https://github.com/json5/json5/issues/106#issuecomment-196993436)). In the same thread Kishore drew a line at functions, saying a core tenet is that "it's just data", not executable code ([comment](https://github.com/json5/json5/issues/106#issuecomment-196379851)). The operators never entered the specification, and the recorded closing reason is that the request was incompatible with it. Adjacent string literals as a form of concatenation ([spec #9](https://github.com/json5/json5-spec/issues/9)) were pointed to the same discussion.

### Workaround

Write the computed value, put the arithmetic in a comment, and name the unit in the key:

``const cfg = JSON5.parse(`{ cacheTtlSeconds: 86400, // 24 * 60 * 60 maxBytes: 0x500000, // 5 MiB }`); // { cacheTtlSeconds: 86400, maxBytes: 5242880 } JSON5.parse('{ms: 24*60*60*1000}'); // SyntaxError: invalid character '*' at 1:8``

Avoid evaluating expression strings with `eval`; see the [security guide](https://json5.dev/tutorials/security/).

![Search icon](https://json5.dev/images/icons/search.png)

## Regular Expressions

**Status:** Not in the specification. [json5 #91](https://github.com/json5/json5/issues/91), retitled to ask only about serializing RegExp objects as strings, was still open. A collaborator proposed closing it in October 2026.

### Recorded reason

In 2015 Tucker saw little demand: it "isn't really a feature that anyone has been asking for or that seems to be lacking" ([comment](https://github.com/json5/json5/issues/91#issuecomment-146758763)). A month later he listed problems (not everything between two slashes is a valid pattern, evaluating the text to find out would be a security risk, and ECMAScript regular expressions cannot express everything PCRE can) and concluded:

> "The best way to serialize regular expressions is to convert them to strings."
> 
> Jordan Tucker, [json5 #91, November 2015](https://github.com/json5/json5/issues/91#issuecomment-154584877)

In 2016 he expanded the argument: a parser would have to tell a pattern from a `//` comment and track escapes and character classes, and it still could not validate the pattern in an implementation-neutral way without far more code ([comment](https://github.com/json5/json5/issues/91#issuecomment-197048166)).

He later prototyped an opt-in `regExps` option. Kishore hesitated at "the idea of different implementations supporting different opt-in features" ([comment](https://github.com/json5/json5/issues/91#issuecomment-332359187)) and preferred not to take it on before 1.0. Asked in 2021 whether the option had ever shipped, Tucker answered no and pointed to a [reviver](https://json5.dev/glossary/#reviver) that does the same job ([comment](https://github.com/json5/json5/issues/91#issuecomment-832241076)).

### Workaround

Store source and flags separately. Version 2.2.3 writes a RegExp object as `{}`, so always supply a [replacer](https://json5.dev/glossary/#replacer).

`const text = "{ pattern: { source: '^v\\\\d+\\\\.\\\\d+$', flags: 'i' } }"; const cfg = JSON5.parse(text, (k, v) => (k === 'pattern' ? new RegExp(v.source, v.flags) : v)); cfg.pattern; // /^v\d+\.\d+$/i cfg.pattern.test('V2.1'); // true JSON5.stringify({ re: /ab+c/i }); // '{re:{}}' JSON5.stringify(cfg, (k, v) => (v instanceof RegExp ? { source: v.source, flags: v.flags } : v));`

Compile patterns only from trusted documents; a hostile pattern can make matching extremely slow.

![Quote icon](https://json5.dev/images/icons/quote.png)

## Backtick Template Strings

**Status:** Declined repeatedly: [json5 #125](https://github.com/json5/json5/issues/125), [json5 #162](https://github.com/json5/json5/issues/162), [json5 #252](https://github.com/json5/json5/issues/252), [json5 #302](https://github.com/json5/json5/issues/302), [spec #16](https://github.com/json5/json5-spec/issues/16) and [spec #34](https://github.com/json5/json5-spec/issues/34).

### Recorded reason

Template literals arrived in ECMAScript 2015, after the edition JSON5 is built on. Several requests asked only for multiline text without interpolation; the answer was the same.

> "Unfortunately, one of the core tenets of JSON5 is that it must be compatible with ES5. Since this suggestion is not, I'm going to close it."
> 
> Jordan Tucker, [spec #16, August 2019](https://github.com/json5/json5-spec/issues/16#issuecomment-518416907)

> "JSON5 adheres to the syntax of ECMAScript 5. This is to ensure long-term compatibility and also to avoid scope creep and bloat."
> 
> Jordan Tucker, [spec #34, October 2021](https://github.com/json5/json5-spec/issues/34#issuecomment-939519975)

The refusal is about the rule more than the feature. In October 2019 Tucker wrote that if there was one ES6 feature he would add, it would be backtick strings, while noting that they still would not handle indented multiline text ([json5 #190](https://github.com/json5/json5/issues/190#issuecomment-544627483)).

### Workaround

Use single or double quotes. For long text, use a line continuation or an array of lines (shown under [multiline strings](#multiline)). Interpolation belongs to the variable approach above.

``JSON5.parse('{s: `hi`}'); // SyntaxError: invalid character '`' at 1:5 JSON5.parse("{s: 'say `hi`'}"); // { s: 'say `hi`' }: backticks are plain characters inside quotes``

![Code icon](https://json5.dev/images/icons/code.png)

## Hexadecimal Floating Point

**Status:** Declined in 2012 ([json5 #26](https://github.com/json5/json5/issues/26)).

### Recorded reason

The request was for C-style hexadecimal floating point, such as `0x1.8p1`, to store doubles without a decimal conversion. The requester noted it was not ES5 and argued for breaking with JavaScript. Kishore replied:

> "I hear you, but I don't think breaking compatibility with JS is something I'm ready to accept just yet. I really do want to keep it "JavaScript Object Notation"."
> 
> Aseem Kishore, [json5 #26, June 2012](https://github.com/json5/json5/issues/26#issuecomment-6253106)

### Workaround

JavaScript writes a double with enough decimal digits to read back the same value, so a normal number usually suffices. Negative zero is the exception in `stringify`. When another system needs the exact bits, store them as a hex string.

`const x = 0.1 + 0.2; JSON5.stringify(x); // '0.30000000000000004' JSON5.parse(JSON5.stringify(x)) === x; // true JSON5.stringify(-0); // '0' (the sign is lost on output) const buf = Buffer.alloc(8); buf.writeDoubleBE(x); buf.toString('hex'); // '3fd3333333333334' Buffer.from('3fd3333333333334', 'hex').readDoubleBE() === x; // true JSON5.parse('{f: 0x1.8p1}'); // SyntaxError: invalid character '.' at 1:8`

![Key icon](https://json5.dev/images/icons/key.png)

## Binary and Octal Literals

**Status:** Declined. Hexadecimal is the only non-decimal form ([json5 #2](https://github.com/json5/json5/issues/2), [json5 #264](https://github.com/json5/json5/issues/264), [spec #40](https://github.com/json5/json5-spec/issues/40)).

### Recorded reason

There are two different cases. Legacy octal with a leading zero (`0755`) exists in non-strict ES5 and was rejected on purpose. In 2012, after a contributor showed that strict mode disallows it, Kishore wrote "let's disallow leading 0's to avoid confusion" ([json5 #2](https://github.com/json5/json5/issues/2#issuecomment-6060039)). Tucker restated the consequence in 2025: "Since JSON5 does not support octal numbers, leading zeroes are not allowed." ([spec #58](https://github.com/json5/json5-spec/issues/58), which asks for the spec to say so explicitly).

The prefixes `0o` and `0b` are ECMAScript 2015 syntax:

> "Thanks for the suggestion, but we've settled on keeping JSON5's features compatible with ES5, so no ES6 features will be added."
> 
> Jordan Tucker, [spec #40, August 2022](https://github.com/json5/json5-spec/issues/40#issuecomment-1207465448)

### Workaround

Write the value in hex or decimal, or keep the readable form in a string and convert it. `Number()` understands both prefixes on modern runtimes.

`const cfg = JSON5.parse("{ mode: '0o755', mask: 0xF0 }", (k, v) => (k === 'mode' ? Number(v) : v)); // { mode: 493, mask: 240 } Number('0b1010'); // 10 JSON5.parse('{o: 0o755}'); // SyntaxError: invalid character 'o' at 1:6 JSON5.parse('{o: 0755}'); // SyntaxError: invalid character '7' at 1:6`

![Text format icon](https://json5.dev/images/icons/text-format.png)

## Numeric Separators

**Status:** Declined ([spec #23](https://github.com/json5/json5-spec/issues/23), [json5 #219](https://github.com/json5/json5/issues/219), [json5 #153](https://github.com/json5/json5/issues/153)).

### Recorded reason

When the underscore separator was still an ECMAScript proposal, Tucker answered: "Unfortunately, it is not compatible with ES5, so it won't be added to JSON5." ([spec #23, April 2020](https://github.com/json5/json5-spec/issues/23#issuecomment-620346400)). He also set a naming boundary for anyone who extends the syntax:

> "Feel free to extend JSON5, however if you do, please don't call it JSON5 anymore."
> 
> Jordan Tucker, [spec #23, April 2020](https://github.com/json5/json5-spec/issues/23#issuecomment-620360365)

His point was that a parser may accept more than the format, which the spec permits, but a document using the extra syntax is not a JSON5 document.

### Workaround

Group digits in a comment, use hex for bit patterns, or accept a string and strip underscores:

``JSON5.parse('{n: 1_000_000}'); // SyntaxError: invalid character '_' at 1:6 const cfg = JSON5.parse(`{ budget: 1000000, // 1_000_000 limit: '2_500_000', }`, (k, v) => (k === 'limit' ? Number(v.replaceAll('_', '')) : v)); // { budget: 1000000, limit: 2500000 } Number('1_000'); // NaN: Number() does not accept separators``

![List icon](https://json5.dev/images/icons/list.png)

## Omitted Array Elements

**Status:** Declined ([json5 #19](https://github.com/json5/json5/issues/19)). Leading commas are rejected for the same reason.

### Recorded reason

ES5 allows `[,null]`, and an early version of the library accepted such input. The issue was opened to stop that, with Kishore writing "Let's keep it simple and closer to JSON here." When it was reopened, Tucker argued against holes in 2014:

> "If JSON5 allowed leading commas and empty values, old JSON files that used to throw would no longer do so, which could introduce silent and/or hard to find bugs."
> 
> Jordan Tucker, [json5 #19, July 2014](https://github.com/json5/json5/issues/19#issuecomment-50662216)

He added that `undefined` is its own data type and that the format introduces no new data types. Kishore questioned the first argument, since much invalid JSON is valid JSON5, but concluded four days later that he agreed the feature should not be added ([comment](https://github.com/json5/json5/issues/19#issuecomment-50978671)).

### Workaround

Write `null` for an empty position. A single trailing comma never creates an element.

`JSON5.parse('[1, null, 3]'); // [ 1, null, 3 ] JSON5.parse('[1, 2,]').length; // 2 JSON5.parse('[1,,3]'); // SyntaxError: invalid character ',' at 1:4 JSON5.stringify([1, , 3]); // '[1,null,3]'`

![Hidden icon](https://json5.dev/images/icons/hidden.png)

## The undefined Value

**Status:** Declined ([spec #5](https://github.com/json5/json5-spec/issues/5), [json5 #171](https://github.com/json5/json5/issues/171)). An earlier request, [json5 #151](https://github.com/json5/json5/issues/151), was closed by its own author without discussion.

### Recorded reason

Answering a request for test data that distinguishes missing from empty, Kishore wrote:

> "Unfortunately, separate distinctions of `undefined` vs. `null` is mostly unique to JS. So if JSON5 supported `undefined`, it wouldn't translate well to many other languages."
> 
> Aseem Kishore, [spec #5, May 2018](https://github.com/json5/json5-spec/issues/5#issuecomment-388569245)

He had made the same point in 2013, in the array-holes discussion: adding `undefined` was unlikely because most languages have no concept of it apart from `null` ([json5 #19](https://github.com/json5/json5/issues/19#issuecomment-21684563)). This is the clearest case of the format choosing portability over matching JavaScript.

### Workaround

Leave the member out to mean "not set" and use `null` to mean "set to nothing":

`const d = JSON5.parse('{ a: null }'); 'a' in d; // true 'b' in d; // false JSON5.parse('{a: undefined}'); // SyntaxError: invalid character 'u' at 1:5 JSON5.stringify({ a: undefined, b: [undefined, 1] }); // '{b:[null,1]}'`

![Document icon](https://json5.dev/images/icons/document.png)

## Multiline Strings Without a Backslash

**Status:** A string may span source lines only with a backslash before each line break. Raw line breaks are declined ([json5 #52](https://github.com/json5/json5/issues/52), [json5 #81](https://github.com/json5/json5/issues/81)).

### Recorded reason

The 2014 request for YAML-style text blocks was closed with Kishore's verdict:

> "I agree, ultimately I think JSON5 needs to remain a subset of ES5, so I don't think we can do this under the JSON5 umbrella."
> 
> Aseem Kishore, [json5 #52, August 2014](https://github.com/json5/json5/issues/52#issuecomment-50978485)

ES5 string literals cannot contain an unescaped line feed or carriage return. What ES5 does offer is the line continuation, which JSON5 adopted. The backslash and the break are removed, so a newline in the result must still be written as `\n`.

### Workaround

``const d = JSON5.parse(`{ oneLine: 'SELECT id, name \\ FROM users \\ WHERE active = 1', keepsBreaks: 'line one\\n\\ line two', joined: [ 'SELECT id', 'FROM users', ], }`); d.oneLine; // 'SELECT id, name FROM users WHERE active = 1' d.keepsBreaks; // 'line one\nline two' d.joined.join('\n'); // 'SELECT id\nFROM users' JSON5.parse('{s: "a\nb"}'); // SyntaxError: invalid character '\n' at 2:0``

Do not indent continuation lines unless you want the spaces in the string. The array form can be indented freely, at the cost of a join in your code.

![Warning icon](https://json5.dev/images/icons/warning.png)

## Duplicate Key Handling

**Status:** Legal syntax with unpredictable behavior. A proposal to define it is open ([spec #38](https://github.com/json5/json5-spec/issues/38)).

### Recorded reason

Unlike the other entries, this is something JSON5 permits and some people want removed. The spec says names should be unique, then allows a parser to report the last pair, fail, or report all pairs. The reference library originally threw on duplicates, behavior inherited from the parser it was modeled on. [json5 #57](https://github.com/json5/json5/issues/57) changed it in 2014 to match `JSON.parse`. A later opt-in error ([pull 217](https://github.com/json5/json5/pull/217)) was declined in 2020 under the no-new-parser-features policy.

When asked to require a "unique" mode in the spec, Tucker explained:

> "The reference implementation uses `last-value-wins` because that's what ES5 does"
> 
> Jordan Tucker, [spec #38, August 2022](https://github.com/json5/json5-spec/issues/38#issuecomment-1229226156)

He also warned that requiring the mode would break existing implementations, including the reference one ([comment](https://github.com/json5/json5-spec/issues/38#issuecomment-1224158640)), while saying he did not think last-value-wins was the best behavior and would be happy to include a `unique` option, off by default then and perhaps on by default in version 3. Version 2.2.3 has none, and neither the unreleased changelog nor the main branch README listed one at this review. A narrower point, that `abc` and `'abc'` are two spellings of the same name, is one Tucker agreed in 2020 should be clarified ([spec #25](https://github.com/json5/json5-spec/issues/25)); the function above treats them that way.

### Workaround

Check the syntax tree in CI. This function uses [Momoa](https://github.com/humanwhocodes/momoa) 3.3.13 in its `json5` mode and compares names after unquoting:

``const momoa = require('@humanwhocodes/momoa'); function duplicateKeys(text) { const found = []; (function walk(node) { if (node.type === 'Document') return walk(node.body); if (node.type === 'Object') { const seen = new Set(); for (const { name, value } of node.members) { const key = name.type === 'String' ? name.value : name.name; if (seen.has(key)) found.push(`${key} at line ${name.loc.start.line}`); seen.add(key); walk(value); } } else if (node.type === 'Array') { node.elements.forEach((element) => walk(element.value)); } })(momoa.parse(text, { mode: 'json5' })); return found; } duplicateKeys("{\n port: 1,\n tls: { on: true },\n 'port': 2,\n}"); // [ 'port at line 4' ] JSON5.parse('{a: 1, a: 2}'); // { a: 2 }``

One limit found in testing: Momoa 3.3.13 rejects a sign directly before a leading decimal point, such as `+.5` or `-.5`. It throws, so the check fails loudly instead of passing a file it did not read.

![Forbidden icon](https://json5.dev/images/icons/forbidden.png)

## Unquoted Strings as Values

**Status:** Names may be unquoted. String values may not ([spec #26](https://github.com/json5/json5-spec/issues/26)).

### Recorded reason

The proposal was `{ foo: bar }`, treating `bar` as a constant that holds its own name. In JavaScript that reads a variable, so it would change what the text means. Tucker answered that "any features that are incompatible with ES5 will not be implemented" ([spec #26, May 2020](https://github.com/json5/json5-spec/issues/26#issuecomment-628881283)). Seven months earlier he had listed it among the things the ES5 rule settles automatically:

> "There is no question as to whether unquoted string values should be supported because ECMAScript doesn't support them."
> 
> Jordan Tucker, [json5 #190, October 2019](https://github.com/json5/json5/issues/190#issuecomment-544627483)

This is the sharpest difference from [Hjson](https://hjson.github.io/), which accepts strings without quotes. The only bare words JSON5 reads as values are `true`, `false`, `null`, `Infinity` and `NaN`.

### Workaround

`JSON5.parse('{ mode: fast }'); // SyntaxError: invalid character 's' at 1:11 JSON5.parse("{ mode: 'fast' }"); // { mode: 'fast' } JSON5.parse('{ null: null, true: Infinity }'); // { null: null, true: Infinity }`

![Infinity icon](https://json5.dev/images/icons/infinity.png)

## The Contested Addition: Infinity and NaN

One addition strains these principles, and the maintainers said so. `Infinity` and `NaN` are valid ES5 expressions, but they let a JSON5 document hold values JSON cannot. In 2016 Tucker proposed removing them ([spec #2](https://github.com/json5/json5-spec/issues/2)). Kishore replied that he had resisted `Date` and `RegExp` because of the "no new datatypes" idea, and that adding these two values "_does_ basically extend the `Number` datatype" ([comment](https://github.com/json5/json5-spec/issues/2#issuecomment-266761103)).

Users argued that scientific and logging data need them. Tucker closed the question in 2017, "Leaving `Infinity` and `NaN` as is for now." ([comment](https://github.com/json5/json5-spec/issues/2#issuecomment-331279685)), and in 2019 added that they are part of the specification "and that will likely never change" ([comment](https://github.com/json5/json5-spec/issues/2#issuecomment-515624060)). In 2021 he was candid that "NaN and Infinity are artifacts that made it into spec", advised implementers to keep parsing them, and said he was not opposed to adding text that discourages their use ([comment](https://github.com/json5/json5-spec/issues/2#issuecomment-864159041)). A related question about platforms that lack these values remains open in [spec #24](https://github.com/json5/json5-spec/issues/24). If you convert to JSON, handle them first:

`const d = JSON5.parse('{n: NaN, i: -Infinity}'); JSON.stringify(d); // '{"n":null,"i":null}'`

A practical reading of the whole record: a request has the best chance when it needs no new syntax. Libraries can add parse and stringify options, schemas can add meaning to strings, and tools can preserve comments, all without changing a single valid document. Requests that need new syntax belong in the [specification repository](https://github.com/json5/json5-spec/issues), where the ES5 rule applies.

![Question icon](https://json5.dev/images/icons/question.png)

## Common Questions

### Will JSON5 ever add ES2015 or later syntax?

The maintainers have said it will not: the README calls ES5 compatibility a fundamental premise. An issue asking for an upgrade remains open in the specification repository, but nothing has been adopted.

### Is an open issue a planned feature?

No. Several open issues propose recommendations, for example on dates, binary data or BigInt, which would add advice to the spec without adding syntax. Open means undecided.

### May my parser accept extra syntax?

The spec lets a parser accept non-JSON5 forms. Generators must produce strictly conforming text, and a document that uses extra syntax is not JSON5.

### Why allow comments but not keep them?

A parser returns data, and comments are not data in the grammar. Preserving them is a job for tools that work on the source text.

### Where should I propose a change?

Format changes go to the `json5-spec` repository. Behavior of the JavaScript library, such as options, goes to the `json5` repository.

## Related Pages

[

![Idea icon](https://json5.dev/images/icons/idea.png)

### Why the Format Exists

The problems it set out to solve.

](https://json5.dev/why/)[

![History icon](https://json5.dev/images/icons/history.png)

### History

How the project developed.

](https://json5.dev/history/)[

![Specification icon](https://json5.dev/images/icons/spec.png)

### ECMAScript Relationship

What comes from ES5 and where they differ.

](https://json5.dev/spec/ecmascript/)[

![Book icon](https://json5.dev/images/icons/book.png)

### Glossary

Definitions of the terms used here.

](https://json5.dev/glossary/)[

![Compare icon](https://json5.dev/images/icons/compare.png)

### Format Comparison

Formats that made different choices.

](https://json5.dev/compare/)

## Sources

(61)

1.  [The JSON5 Data Interchange Format, version 1.0.0](https://spec.json5.org/)
2.  [json5 README: features, compatibility premise, credits](https://github.com/json5/json5)
3.  [Earlier json5 README: no new data types](https://github.com/json5/json5/blob/5cbd65659706f4071e7cbf3aebd4298c0a879c2d/README.md)
4.  [json5 changelog, including unreleased changes](https://github.com/json5/json5/blob/main/CHANGELOG.md)
5.  [ECMAScript Language Specification, Edition 5.1](https://262.ecma-international.org/5.1/)
6.  [json5 issue 2](https://github.com/json5/json5/issues/2)
7.  [json5 issue 3](https://github.com/json5/json5/issues/3)
8.  [json5 issue 19](https://github.com/json5/json5/issues/19)
9.  [json5 issue 26](https://github.com/json5/json5/issues/26)
10.  [json5 issue 52](https://github.com/json5/json5/issues/52)
11.  [json5 issue 57](https://github.com/json5/json5/issues/57)
12.  [json5 issue 81](https://github.com/json5/json5/issues/81)
13.  [json5 issue 91](https://github.com/json5/json5/issues/91)
14.  [json5 issue 106](https://github.com/json5/json5/issues/106)
15.  [json5 issue 112](https://github.com/json5/json5/issues/112)
16.  [json5 issue 125](https://github.com/json5/json5/issues/125)
17.  [json5 issue 148](https://github.com/json5/json5/issues/148)
18.  [json5 issue 151](https://github.com/json5/json5/issues/151)
19.  [json5 issue 153](https://github.com/json5/json5/issues/153)
20.  [json5 issue 162](https://github.com/json5/json5/issues/162)
21.  [json5 issue 171](https://github.com/json5/json5/issues/171)
22.  [json5 issue 177](https://github.com/json5/json5/issues/177)
23.  [json5 issue 186](https://github.com/json5/json5/issues/186)
24.  [json5 issue 190](https://github.com/json5/json5/issues/190)
25.  [json5 issue 201](https://github.com/json5/json5/issues/201)
26.  [json5 issue 219](https://github.com/json5/json5/issues/219)
27.  [json5 issue 252](https://github.com/json5/json5/issues/252)
28.  [json5 issue 264](https://github.com/json5/json5/issues/264)
29.  [json5 issue 292](https://github.com/json5/json5/issues/292)
30.  [json5 issue 302](https://github.com/json5/json5/issues/302)
31.  [json5 pull request 111](https://github.com/json5/json5/pull/111)
32.  [json5 pull request 120](https://github.com/json5/json5/pull/120)
33.  [json5 pull request 217](https://github.com/json5/json5/pull/217)
34.  [json5-spec issue 2](https://github.com/json5/json5-spec/issues/2)
35.  [json5-spec issue 4](https://github.com/json5/json5-spec/issues/4)
36.  [json5-spec issue 5](https://github.com/json5/json5-spec/issues/5)
37.  [json5-spec issue 7](https://github.com/json5/json5-spec/issues/7)
38.  [json5-spec issue 8](https://github.com/json5/json5-spec/issues/8)
39.  [json5-spec issue 9](https://github.com/json5/json5-spec/issues/9)
40.  [json5-spec issue 16](https://github.com/json5/json5-spec/issues/16)
41.  [json5-spec issue 20](https://github.com/json5/json5-spec/issues/20)
42.  [json5-spec issue 23](https://github.com/json5/json5-spec/issues/23)
43.  [json5-spec issue 24](https://github.com/json5/json5-spec/issues/24)
44.  [json5-spec issue 25](https://github.com/json5/json5-spec/issues/25)
45.  [json5-spec issue 26](https://github.com/json5/json5-spec/issues/26)
46.  [json5-spec issue 32](https://github.com/json5/json5-spec/issues/32)
47.  [json5-spec issue 34](https://github.com/json5/json5-spec/issues/34)
48.  [json5-spec issue 35](https://github.com/json5/json5-spec/issues/35)
49.  [json5-spec issue 36](https://github.com/json5/json5-spec/issues/36)
50.  [json5-spec issue 38](https://github.com/json5/json5-spec/issues/38)
51.  [json5-spec issue 40](https://github.com/json5/json5-spec/issues/40)
52.  [json5-spec issue 56](https://github.com/json5/json5-spec/issues/56)
53.  [json5-spec issue 58](https://github.com/json5/json5-spec/issues/58)
54.  [json5-spec v1.1.0 branch (unreleased)](https://github.com/json5/json5-spec/tree/v1.1.0)
55.  [RFC 3339: Date and Time on the Internet](https://www.rfc-editor.org/rfc/rfc3339)
56.  [Momoa README](https://github.com/humanwhocodes/momoa)
57.  [golden-fleece README](https://github.com/Rich-Harris/golden-fleece)
58.  [@croct/json5-parser README](https://github.com/croct-tech/json5-parser-js)
59.  [json-five README](https://github.com/spyoungtech/json-five)
60.  [json5format README](https://github.com/google/json5format)
61.  [Hjson](https://hjson.github.io/)

Last reviewed: November 29, 2026.
