JSON5 Validator

Validate JSON5 and convert it to standard JSON.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

JSON5 Validator and JSON5 to JSON Converter

This JSON5 validator checks JSON5 documents and converts them to standard JSON in one step. Paste a config file with comments, unquoted keys, or trailing commas; if it's valid you get strict JSON on the right plus structure statistics, and if not you get the exact line and column of the error.

What JSON5 allows

JSON5 extends JSON with features from ECMAScript 5 that make hand-written files friendlier:

  • Comments – // line and /* block */.
  • Unquoted keys – { port: 8080 } as long as the key is a valid identifier.
  • Single-quoted strings and strings that span lines with a trailing backslash.
  • Trailing commas in objects and arrays.
  • Flexible numbers – hexadecimal (0xFF), leading or trailing dots (.5, 5.), explicit plus signs, Infinity, and NaN.

Where you'll meet JSON5

Babel configuration, some bundler and linter configs, Chromium preference files, and many internal tools use JSON5 because comments help document settings. VS Code's JSONC format (settings.json, tsconfig.json) is a subset of JSON5, so those files validate here as well.

Converting to strict JSON

Most APIs and languages only understand strict JSON. The converted output removes comments, quotes every key, uses double quotes for strings, and drops trailing commas. Note that Infinity and NaN have no JSON equivalent; they become null, just like JSON.stringify does in JavaScript.

For strict JSON, use the JSON Validator. If a file is broken in ways even JSON5 doesn't allow, the JSON Fixer tries to repair it. For another popular config format, see the TOML Validator.

Frequently Asked Questions

JSON5 is a superset of JSON designed for files people write by hand. It allows comments, unquoted keys, single-quoted strings, trailing commas, hexadecimal numbers, leading or trailing decimal points, Infinity and NaN, and multi-line strings.

Yes. JSON5 only adds syntax, so any valid JSON document is also valid JSON5. The opposite is not true, which is why JSON5 files must be converted before strict JSON parsers can read them.

Comments are removed, because standard JSON has no comment syntax. Everything else — keys, values, and structure — is preserved in the converted JSON.

Yes. JSONC is JSON with comments and trailing commas, which is a subset of JSON5, so settings.json, tsconfig.json, and similar files validate here.