A JSON5 validator with clear results
This JSON5 validator parses your document with the reference JSON5 parser and tells you whether it is valid. Because JSON5 is looser than JSON, a normal JSON validator rejects perfectly good JSON5 files, while a text editor may not catch a real mistake. Here you get a definite answer and the exact position of the first problem.
The three possible results
| Status bar | Meaning |
|---|---|
| Valid JSON5 (also valid strict JSON) ✓ | The document uses no JSON5 extensions. Any JSON parser can read it. |
| Valid JSON5 ✓ | It relies on at least one JSON5 feature, such as a comment, an unquoted key or a trailing comma. Only JSON5-aware tools can read it. |
| invalid character … at line:column | A syntax error, with its line and column. |
The difference between the first two is useful when you are unsure whether a file will work with a strict parser.
Example
A missing comma is the classic error in hand-edited config:
{
name: 'dashboard'
debug: false,
}
The validator reports invalid character 'd' at 3:3: the parser expected a comma or a closing brace before debug on line 3. Add the comma after 'dashboard' and the result becomes "Valid JSON5 ✓", with the document shown reformatted in the output panel (comments are left out of that view).
Errors JSON5 still does not allow
JSON5 is relaxed, but not anything goes. These are rejected:
- Two commas in a row, as in
{a:1,,}. Only one trailing comma is allowed. - Hyphens in unquoted keys, such as
log-level: 1. Keys must be valid identifiers or be quoted. - Leading zeros, as in
01. Hex like0x1Fis fine. undefined, which is a JavaScript value, not a JSON5 one.- An unescaped apostrophe inside a single-quoted string: write
'it\'s'or use double quotes. - An unclosed block comment or bracket, reported as
invalid end of input.
Where JSON5 files come from
JSON5 is used for hand-maintained configuration in JavaScript tooling. Babel, for example, parses its .babelrc files as JSON5, which is why they may contain comments. Files in the "JSON with Comments" style used by VS Code settings and tsconfig.json generally validate as JSON5 too, because JSON5 permits their comments and trailing commas.
To restyle a valid file, use the JSON5 formatter. For plain JSON documents, the JSON validator checks against the stricter grammar. Validation runs in your browser, and the file is not uploaded.