JSON5 Conformance and Test Suite

What the spec requires, what the official tests check, and how 15 parser builds scored when we ran them.

The official corpus, json5/json5-tests, is 114 small documents whose file extensions declare whether a parser should accept them. This page maps its layout, counts every category and prints the runner scripts.

The results come from our own run on November 29, 2026, against JavaScript and Python libraries at exact versions, with each failing case explained, extra probes for gaps in the corpus, and clear limits.

A test bench sorting JSON5 test files into valid and invalid trays beside a parser results board

TL;DR: The corpus holds 114 cases: 83 valid and 31 invalid. In our run, json5 2.2.3, six other JavaScript builds and two Python libraries scored 114 of 114; six parsers did not. The spec requires parsers to accept every valid text but permits extensions, and a perfect score still leaves gaps, as one end-of-input bug shows.

Spec icon

What Conformance Means in the Spec

The JSON5 Data Interchange Format, version 1.0.0 (March 2018) defines conformance in two short sections and one annex. It is far narrower than many readers expect, and the difference matters when you read a pass count.

Spec sectionRequirementWhat it means for testing
10, ParsersA parser must accept all texts that conform to the grammar.Rejecting a valid document is a conformance failure, unless a permitted limit explains it.
10, ParsersA parser may accept non-JSON5 forms or extensions.Accepting an invalid document is not forbidden by this clause.
10, ParsersAn implementation may limit text size, nesting depth, number range and precision, and the length and character contents of strings.Some rejections are legitimate limits.
11, GeneratorsOutput must strictly conform to the grammar.Writers are held to a stricter rule than readers. The test suite does not test writers at all.
5.2, SeparatorsParsers should warn about unescaped U+2028 and U+2029 in strings.A recommendation. Silence is not a failure.
A, ConformanceKey words follow RFC 2119 but are written in lower case. All text is normative except marked non-normative sections, examples and notes.Lower-case "must" and "may" carry the formal meaning.

Read "invalid input rejected" carefully. The official suite expects invalid cases to fail. A parser that accepts one is lenient: it disagrees with the suite and with the grammar about what a JSON5 text is, but section 10 allows extensions. It matters in practice because a file your lenient parser accepts may fail everywhere else. See the grammar reference.

The spec also does not prescribe how parsed values map to a programming language. Whether -0 keeps its sign, or a large integer stays exact, is outside the grammar; those edge cases are collected in open questions in the spec.

GitHub logo

The json5-tests Repository

The official corpus is json5/json5-tests, MIT licensed (copyright 2012-2016 Aseem Kishore and contributors). The GitHub repository was created on September 28, 2016, and its git history of 265 commits reaches back to May 2012. The commit tested here is ceb24d4 of February 19, 2026, merged through pull request #3. The commit before it dates from November 2016.

A fresh clone tracks 126 files: 114 test cases, 8 .errorSpec files, two configuration files inside new-lines/, a README and a license. There is no runner, no package manifest and no expected-output files. Each case is a single small document in a folder named for the feature it exercises.

json5-tests/ README.md the extension convention LICENSE.md MIT arrays/ commas in arrays comments/ line and block comments misc/ larger documents, whitespace, empty input new-lines/ LF, CR and CRLF (marked binary in .gitattributes) numbers/ decimal, hex, signs, Infinity, NaN, octal objects/ keys and commas strings/ quoting and line continuation todo/ Unicode identifier keys

The suite is not the maintainers' primary regression test. In a May 2020 reply on issue #2, maintainer Jordan Tucker said this repository was outdated and recommended testing against the tests in the main json5/json5 repository. Those are JavaScript test files tied to that library's API, so the standalone corpus remains the language-neutral option. Treat it as a floor.

Code file icon

The File Extension Is the Expected Result

The README encodes each expectation in the file extension, using two older grammars as references: strict JSON and ECMAScript 5.

ExtensionMeaning in the READMEExpected resultReference oracleCases
.jsonValid JSON must remain valid JSON5Parse succeedsJSON.parse()26
.json5New JSON5 features, still valid ES5Parse succeedseval()57
.jsValid ES5 that JSON5 explicitly disallowsParse failsnone needed6
.txtInvalid ES5 must remain invalidParse failsnone needed25

That gives 83 documents that must parse and 31 that should be rejected. For a valid case, a runner should compare the parsed value with the oracle's value, not merely check that nothing threw. Comparison needs care: NaN is unequal to itself and -0 === 0 is true in JavaScript, so a naive equality test hides real differences.

eval() runs code. The convention asks you to evaluate every .json5 file. Review the files at the commit you test, and never point this runner at documents you did not inspect. Application code must never parse input this way; see the security guide.

The errorSpec files

The corpus has eight .errorSpec files, seven of them beside a test case of the same name. Each holds at, lineNumber, columnNumber and message. The README never mentions them, and messages such as Expected ']' instead of 'f' are the wording of one particular parser. The spec says nothing about error messages, so the runner below ignores them. The eighth, strings/no-comma-array.errorSpec, has no matching test case in strings/ and spells a key columNumber.

One case that breaks the convention

comments/irregular-block-comment.json is the file added in February 2026. It holds true followed by a block comment, checking that /*/ does not close a comment and that comments do not nest. Because of the comment it is not JSON: JSON.parse throws on it, so the README's oracle cannot produce an expected value. Issue #4, opened October 13, 2026 and still open on November 29, proposes renaming it to .json5. The runner here notes the oracle failure and takes the expected value from eval.

Table icon

Categories and Counts

These counts were computed by the runner from a fresh clone on November 29, 2026. .errorSpec files are not counted as cases.

Folder.json.json5.js.txtTotalWhat it exercises
arrays21216Empty and regular arrays, one trailing comma, leading, lone and missing commas
comments370313Placement of both comment styles, comment markers inside strings, unterminated and comment-only input
misc13015Empty input, a package manifest, the README example, extra whitespace
new-lines06006Comments and escaped line breaks with LF, CR and CRLF
numbers183141467Integers, floats, exponents, decimal-point forms, hex, signed zero, Infinity, NaN, octal-like input
objects240511Unquoted, reserved and single-quoted keys, duplicate keys, bad keys and commas
strings03014Single quotes, line continuation, a raw newline
todo02002Literal and escaped Unicode identifier keys
Total2657625114

The distribution is lopsided. Numbers make up 67 of 114 cases, while strings have only 4. A parser can score 114 of 114 without any test of \x escapes, surrogate pairs, the \0 rule or the banned digit escapes \1 through \9. The todo/ folder is not described in the README; its two documents are valid under the grammar because keys are ECMAScript 5.1 identifier names, so they are included in the totals.

Terminal icon

How to Run the Suite

The suite ships no runner, so here is the one that produced the results on this page. Clone both repositories with line-ending conversion turned off, then install the parsers into a separate folder.

git clone -c core.autocrlf=false https://github.com/json5/json5-tests.git git clone https://github.com/json5/json5.git json5-main git -C json5-tests checkout ceb24d4080137d70833f86c25659c1331b80a387 git -C json5-main checkout 6d21f2f86f58379171dbbadc5b00d0ae17ab9919 mkdir run && cd run npm init -y && npm pkg set type=module # Save the two scripts below into this folder as run-suite.mjs and run_suite.py npm install --ignore-scripts [email protected] [email protected] @croct/[email protected] [email protected] [email protected] [email protected] @mischnic/[email protected] [email protected] [email protected] @humanwhocodes/[email protected] [email protected] node run-suite.mjs ../json5-tests ../json5-main

Windows users: with core.autocrlf=true, git rewrites most files to CRLF on checkout. Only new-lines/ is protected by its .gitattributes. Clone as shown so that you test the committed bytes.

The commands were written for PowerShell 7 or a Unix-style shell. The unreleased main branch supports Node.js 22.12 and later, according to its changelog.

JavaScript runner: run-suite.mjs

// Usage: node run-suite.mjs <json5-tests dir> <json5 main checkout dir> import { readFileSync, readdirSync, writeFileSync } from 'node:fs'; import { join, extname } from 'node:path'; import { pathToFileURL } from 'node:url'; import JSON5 from 'json5'; import jju from 'jju'; import { JsonParser } from '@croct/json5-parser'; import JSON11 from 'json11'; import { parseJSON5 as confbox } from 'confbox'; import * as fleece from 'golden-fleece'; import sourcemap from '@mischnic/json-sourcemap'; import { parse as tiny } from 'tinyjson5'; import { parseJSON5 as quick } from 'quick-json5'; import { parse as momoaParse, evaluate } from '@humanwhocodes/momoa'; import json5es from 'json5-es'; const [suite, mainDir] = process.argv.slice(2); const main = await import(pathToFileURL(join(mainDir, 'lib', 'index.js'))); const parsers = { 'json5 2.2.3': (s) => JSON5.parse(s), 'json5 main': (s) => main.default.parse(s), 'jju 1.4.0': (s) => jju.parse(s, { mode: 'json5' }), '@croct/json5-parser 0.2.2': (s) => JsonParser.parse(s).toJSON(), 'json11 3.0.0': (s) => JSON11.parse(s), 'confbox 0.3.2': (s) => confbox(s), 'golden-fleece 1.0.9': (s) => fleece.evaluate(s), '@mischnic/json-sourcemap 0.1.1': (s) => sourcemap.parse(s, null, { dialect: 'JSON5' }).data, 'tinyjson5 0.1.2': (s) => tiny(s), 'quick-json5 0.5.0': (s) => quick(s), 'momoa 3.3.13': (s) => evaluate(momoaParse(s, { mode: 'json5' })), 'json5-es 2.1.1': (s) => json5es.parse(s), }; // Tagged form that keeps NaN, Infinity and -0 distinct and ignores prototypes. function canon(v) { if (typeof v === 'number') return ['n', Object.is(v, -0) ? '-0' : String(v)]; if (typeof v === 'bigint') return ['bigint', String(v)]; if (Array.isArray(v)) return ['a', v.map(canon)]; if (v !== null && typeof v === 'object') { return ['o', Object.keys(v).sort().map((k) => [k, canon(v[k])])]; } return [typeof v, v]; } const cases = readdirSync(suite, { recursive: true }) .map((p) => p.replaceAll('\\', '/')) .filter((p) => !p.startsWith('.git') && p.includes('/')) .filter((p) => ['.json', '.json5', '.js', '.txt'].includes(extname(p))) .sort() .map((file) => { const text = readFileSync(join(suite, file), 'utf8'); const ext = extname(file); const c = { file, text, valid: ext === '.json' || ext === '.json5' }; if (c.valid) { let value; try { // The README's oracle: JSON.parse for .json, eval for .json5. value = ext === '.json' ? JSON.parse(text) : (0, eval)(`(${text}\n)`); } catch (e) { // Suite defect: fall back to ES evaluation and say so. c.oracleError = e.message; value = (0, eval)(`(${text}\n)`); } c.expected = canon(value); } return c; }); console.log(`${cases.length} cases`); const tally = {}; for (const c of cases) { const [dir] = c.file.split('/'); tally[dir] ??= { json: 0, json5: 0, js: 0, txt: 0 }; tally[dir][extname(c.file).slice(1)]++; if (c.oracleError) console.log(`oracle failed: ${c.file}: ${c.oracleError}`); } console.table(tally); console.warn = () => {}; // json5 2.x warns about raw U+2028 / U+2029 for (const [name, parse] of Object.entries(parsers)) { const fails = []; for (const c of cases) { try { const got = parse(c.text); if (!c.valid) { fails.push([c.file, 'ACCEPTED', String(JSON.stringify(canon(got)))]); } else if (JSON.stringify(canon(got)) !== JSON.stringify(c.expected)) { fails.push([c.file, 'WRONG VALUE', JSON.stringify(canon(got))]); } } catch (e) { if (c.valid) fails.push([c.file, 'REJECTED', e.message.split('\n')[0]]); } } console.log(`\n${name}: ${cases.length - fails.length}/${cases.length}`); for (const f of fails) console.log(' ' + f.map((x) => x.slice(0, 150)).join(' | ')); } writeFileSync('cases.json', JSON.stringify(cases));

Python runner: run_suite.py

# Usage: <venv python> -I run_suite.py cases.json <json5|pyjson5|json-five> import json import math import sys from importlib.metadata import version cases_path, dist = sys.argv[1], sys.argv[2] if dist == "pyjson5": import pyjson5 as lib else: import json5 as lib # both json5 and json-five install a "json5" module def same(expected, got): tag, val = expected if tag == "n": if isinstance(got, bool) or not isinstance(got, (int, float)): return False want = float(val) if math.isnan(want): return math.isnan(got) if got != want: return False # A Python int cannot carry the sign of zero; only floats are checked. if want == 0 and isinstance(got, float): return math.copysign(1, got) == math.copysign(1, want) return True if tag == "a": return (isinstance(got, list) and len(got) == len(val) and all(map(same, val, got))) if tag == "o": if not isinstance(got, dict): return False d = dict(val) return d.keys() == got.keys() and all(same(d[k], got[k]) for k in d) if tag == "string": return isinstance(got, str) and got == val if tag == "boolean": return got is val return got is None # null with open(cases_path, encoding="utf-8") as f: cases = json.load(f) fails = [] for c in cases: try: got = lib.loads(c["text"]) except Exception as e: # any exception counts as a rejection if c["valid"]: msg = (str(e).splitlines() or [""])[0] fails.append((c["file"], "REJECTED", type(e).__name__ + ": " + msg)) continue if not c["valid"]: fails.append((c["file"], "ACCEPTED", repr(got))) elif not same(c["expected"], got): fails.append((c["file"], "WRONG VALUE", repr(got))) print(f"{dist} {version(dist)}: {len(cases) - len(fails)}/{len(cases)}") for row in fails: print(" " + ascii(" | ".join(x[:150] for x in row))[1:-1])

The Node script writes cases.json, which holds each document and its expected value in a tagged form. The Python script reads it, so both languages are judged against the same oracle. The json5 and json-five packages both install a module named json5, so give every library its own virtual environment.

python -m venv py-json5 && py-json5/Scripts/python -m pip install json5==0.17.3 python -m venv py-pyjson5 && py-pyjson5/Scripts/python -m pip install pyjson5==2.0.1 python -m venv py-jsonfive && py-jsonfive/Scripts/python -m pip install json-five==1.1.2 py-json5/Scripts/python -I run_suite.py cases.json json5 py-pyjson5/Scripts/python -I run_suite.py cases.json pyjson5 py-jsonfive/Scripts/python -I run_suite.py cases.json json-five # On Linux and macOS the interpreter is in bin/ instead of Scripts/

One concession is built into the Python comparison: a Python int has no negative zero, so when a parser returns an integer zero for -0 the sign is not checked. Floating-point zeros are checked.

Test icon

Run It Yourself in the Browser

You do not have to take the table below on trust, or clone anything. This button runs all 114 cases of the official corpus, at the same commit, through the copy of the reference parser that this site ships for its online tools. Each valid document must parse to the value the corpus oracle gives, and each invalid document must be rejected. The run happens in your browser tab and takes well under a second.

Not run yet.

The expected values were computed ahead of time with the oracle the corpus README names (JSON.parse for .json files, evaluation as ECMAScript for .json5 files) and are stored with the cases, because a page under a strict content security policy cannot evaluate text as code. The comparison keeps NaN, Infinity and -0 distinct, exactly as the command-line runner below does. The result should match the first row of the results table. If it does not, your browser's JavaScript engine disagrees with ours on a number or string edge case, and the failing files are listed.

Checklist icon

Results Matrix, November 29, 2026

Environment: Windows 11, Node.js 24.22.1 and Python 3.14.4. Test corpus at commit ceb24d4. Every parser ran with default options, except that jju and Momoa were set to their JSON5 mode (mode: 'json5') and @mischnic/json-sourcemap to dialect: 'JSON5'. No case produced a wrong value in any parser; every failure is a wrong accept or a wrong reject.

Parser and versionLanguageValid accepted (of 83)Invalid rejected (of 31)Total (of 114)
json5 2.2.3 (reference, latest release)JavaScript8331114
json5 main at 6d21f2f (unreleased)JavaScript8331114
json11 3.0.0JavaScript8331114
confbox 0.3.2 parseJSON5JavaScript8331114
tinyjson5 0.1.2JavaScript8331114
quick-json5 0.5.0JavaScript8331114
json5-es 2.1.1JavaScript8331114
json5 0.17.3Python8331114
pyjson5 2.0.1Python (Cython)8331114
@mischnic/json-sourcemap 0.1.1JavaScript8231113
golden-fleece 1.0.9JavaScript8131112
json-five 1.1.2Python8131112
@croct/json5-parser 0.2.2JavaScript8031111
jju 1.4.0JavaScript8325108
@humanwhocodes/momoa 3.3.13JavaScript7929108

These rows are not 15 independent implementations. The confbox README says its JSON5 support comes from the json5 project, and tinyjson5 describes itself as following the rules of the unreleased main branch. For library choice beyond conformance, see implementations, JavaScript and Python.

Bug icon

Every Failing Case, Explained

ParserCasesWhat happenedSpec reading
jju 1.4.0Six numbers/*octal.txt filesAccepts a leading zero as legacy octal: the positive octal case returns 83 and numbers/octal.txt returns 8.An extension, allowed by section 10, but the same text is an error in the reference parser.
momoa 3.3.13Four signed leading-decimal-point casesRejects a sign followed directly by a decimal point, with Unexpected character '.'. The unsigned form passes.Violates the "must accept" rule.
momoa 3.3.13numbers/lone-decimal-point.txtAccepts a lone . and evaluates it to NaN.Lenient.
momoa 3.3.13strings/unescaped-multi-line-string.txtAccepts a raw line feed inside a string.Lenient.
@croct/json5-parser 0.2.2objects/reserved-unquoted-key.json5, misc/readme-example.json5Rejects the key while as a reserved identifier.Violates "must accept": a key is an IdentifierName, which includes reserved words.
@croct/json5-parser 0.2.2todo/unicode-escaped-unquoted-key.json5Rejects a \uXXXX escape inside an unquoted key.Violates "must accept".
golden-fleece 1.0.9Both todo/ casesRejects non-ASCII letters and escapes in unquoted keys.Violates "must accept".
@mischnic/json-sourcemap 0.1.1numbers/hexadecimal-uppercase-x.json5Rejects 0XC8.Violates "must accept": section 6 allows upper-case X.
json-five 1.1.2new-lines/comment-cr.json5, new-lines/escaped-cr.json5A line comment ended only by a carriage return swallows the rest of the file.Violates "must accept": CR is a line terminator.

The json-five diagnosis was confirmed separately: {a:1}\r and an escaped CR inside a string both parse, while a // comment ended by CR does not.

Search icon

Beyond the Suite: 20 Extra Probes

A full score only covers what the files contain. The same parsers were given 20 more inputs derived from the grammar, checking acceptance only (not values). "Disagrees" lists the parsers whose accept or reject decision differs from the grammar.

ProbeInputGrammar saysDisagrees
Binary literal0b1invalidgolden-fleece
ES2015 octal0o7invalidjju, golden-fleece
BigInt suffix1ninvalidjson11
Digit separator1_000invalidpyjson5
Leading zero01invalidjju
Leading zeros with fraction00.5invalidnone
Code point escape"\u{1F600}"invalidjson-five
Digit escape"\1"invalidjju, golden-fleece, momoa, json-five
Short hex escape"\x4"invalidnone
Zero escape then digit"\01"invalidjju, golden-fleece, momoa, pyjson5
Template literal`a`invalidnone
Double sign--1invalidnone
Two top-level values{} {}invalidnone
Lone comma[,]invalidnone
Signed NaN+NaNvalidgolden-fleece
Hex at end of input0xFFvalidjson5-es
U+3000 before a value\u3000[1] (literal character)valid@mischnic/json-sourcemap, json-five
Raw U+2028 in a stringliteral character between quotesvalidjju, @croct/json5-parser, json-five
Reserved word key{while: 1}valid@croct/json5-parser
Lone surrogate escape"\uDEAD"validpyjson5 (a limit the spec permits)

No disagreement appeared on these probes for json5 2.2.3, json5 main, confbox, tinyjson5, quick-json5 or the Python json5 package. That is a statement about 20 inputs, not a proof of correctness.

A bug that a perfect score hides

json5-es passes all 114 files, yet parse('0xFF') throws Invalid string length, while the same text followed by a newline returns 255. Every hex case in the corpus has a line break after the literal, so the failure never shows. The reference package had the same symptom in an old release: the tinyjson5 README documents it for json5 1.0.2, and parse('0x1') on that version threw RangeError: Invalid string length when we tried it.

To measure the gap, we stripped the trailing line breaks from every file that has them (81 of 114) and ran all 15 builds again. Only json5-es changed its behavior, on nine hexadecimal cases in numbers/. Runner authors can add this second pass at almost no cost.

Permitted limits versus failures

pyjson5 rejects lone surrogates, which the clause on "character contents of strings" permits. In a separate check it also raised Json5EOF for 1e309 and 1e1000, where the other two Python libraries return infinity; the clause on number range covers a limit, although the error text does not describe one.

Target icon

How to State a Conformance Claim

No certification program is described in the spec or the test repository, so a claim is only as good as the detail behind it. A useful statement includes the following.

  • The spec version (1.0.0) and the corpus commit hash. The corpus has no releases to cite, so a hash is the only stable name.
  • The parser version, runtime version and every non-default option.
  • Separate counts for valid documents accepted and invalid documents rejected. The first maps to the "must" in section 10; the second to strictness.
  • Whether values were compared, how -0 and NaN were handled, and which cases used a substitute oracle.
  • Declared limits on nesting, number range and string contents.
  • For a writer: a round trip of your output through an independent parser, since the corpus tests no generator.

Good wording: "Version X accepts all 83 valid documents and rejects all 31 invalid documents of json5-tests at ceb24d4 with default options." Avoid "fully compliant" on the strength of the corpus alone. If you are writing a parser, pair it with the syntax reference and add your own cases for escapes, identifiers and white space.

Warning icon

Limits of What Was Tested

  • Only the JavaScript and Python parsers listed above were run. Nothing here says anything about Go, Rust, Java, C#, C or other implementations.
  • One operating system and one version each of Node.js and Python. Browser builds, ESM versus CommonJS entry points and older runtimes were not tested.
  • Only the string parsing entry point was called. Revivers, hooks, streaming, byte input, comment preservation and editing APIs were not tested.
  • No serializer was tested.
  • Error messages and positions, performance, memory use, deep nesting and hostile input were not measured.
  • Value comparison ignores object key order and prototypes. Integer negative zero is not checked in Python.
  • The 20 probes were chosen by hand. They are examples, not a coverage measure.
  • A failure describes the listed version on this date. Check the current release before ruling a library out.

Common Questions

Is there an official JSON5 certification?

The spec and the test repository describe none. Conformance is self-declared, so publish the corpus commit, parser version, options and both counts.

Does a parser that accepts octal numbers violate the spec?

Octal input is not JSON5, but section 10 lets a parser accept extensions. It does fail the corresponding corpus cases, and documents that rely on it are not portable.

Why does JSON.parse fail on one of the .json cases?

The irregular block comment case contains a comment. It is valid JSON5 but not JSON, and issue #4 in the test repository proposes renaming it.

Are JSON files always valid JSON5?

The spec calls JSON5 a superset of JSON, and all strict JSON cases in the corpus parsed in every tested library. See the format comparison for the differences in the other direction.

Does the suite test stringify functions?

No. Every case is parser input. The generator rule in section 11 has to be tested some other way, for example by parsing your output with a second implementation.