JSON5 Validator
FV-33Paste JSON5 to check that it is valid. You get the line and column of the first error, or a note on what the top-level value is. You can also convert it to strict JSON.
Runs in your browser. Nothing is uploaded.
JSON5
Result
How to use it
- Paste your JSON5 into the input box, or open a file or drop it on the box.
- Click Validate JSON5 to check it. The result shows below the box.
- Click Convert to JSON if you want strict JSON, then pick the indent.
- Copy the result or download it as a .json file.
What counts as valid JSON5
JSON5 is JSON with the conveniences of JavaScript object syntax. Comments are allowed, keys can be unquoted, strings can use single quotes and span lines with a backslash, trailing commas are fine, numbers can be hex, start or end with a decimal point, or be Infinity or NaN. The check uses the json5 library, which follows the JSON5 specification, so text that passes here parses the same way in other JSON5 tools.
What validation does not check
Validation says whether the text is JSON5 and what the top-level value is, such as an object with 5 keys. It does not flag repeated keys, which JSON5 allows, and it does not check number precision. A number with more digits than JavaScript can hold is still valid JSON5 even though a program that reads it into a normal number would round it. It also knows nothing about your data model.
Converting to JSON
Convert to JSON writes strict JSON: comments are dropped, keys are quoted, single quotes become double quotes, and hex numbers become decimal. Numbers are read as JavaScript numbers, so a very long integer can be rounded in the output. Infinity and NaN cannot be written in JSON, so the conversion stops with an error instead of guessing a replacement.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Invalid JSON5: invalid character '}' at line 2, column 4 | A character appears where JSON5 does not allow it, here a } where a value was expected. | Check the position shown. Add the missing value or remove the stray character. |
Questions people ask
How do I validate JSON5?
Paste the text and click Validate JSON5. A valid document returns Valid JSON5 and what it holds, for example an object with 5 keys. An invalid one returns the error with the line and column where parsing stopped.
What is the difference between JSON and JSON5?
JSON5 is a superset of JSON that allows comments, unquoted keys, single quotes, trailing commas, hex numbers and a few more JavaScript-style forms. Any valid JSON is valid JSON5, but JSON5 text is often not valid JSON, so standard JSON parsers reject it.
Are comments allowed in JSON5?
Yes. Both // line comments and /* block */ comments are valid. That is one of the main reasons people use JSON5 for config files. When you convert to strict JSON, the comments are dropped because JSON has no comment syntax.
Why does it not report duplicate keys?
The JSON5 specification does not forbid repeated keys, and the library keeps the last value. This tool follows that, so a repeated key passes. If you need to catch duplicates, scan the keys yourself or use a linter with that rule.
Can JSON5 hold big numbers exactly?
The text can contain any number of digits and still be valid. But once a program reads it into a standard number, anything above 2 to the power of 53 can be rounded. Convert to JSON here rounds in the same way, so keep long IDs as strings.
How do I convert JSON5 to JSON?
Click Convert to JSON. Comments are removed, keys and strings get double quotes, trailing commas disappear and hex numbers turn into decimal. If the file contains Infinity or NaN the conversion stops with an error, because JSON cannot represent them.
About this tool
Parses the text with the json5 library, which follows the JSON5 specification: comments, unquoted keys, single-quoted strings, trailing commas, hex numbers, leading or trailing decimal points, Infinity and NaN. Validate answers whether the text is JSON5 and describes the top-level value. It does not flag repeated keys, which JSON5 allows, and it does not check numbers for precision. Convert to JSON writes strict JSON and drops comments, and it rounds numbers that JavaScript cannot hold exactly, which can change very long integers; it refuses Infinity and NaN because JSON cannot hold them. The error position is where the parser gave up and can sit just after the actual mistake.