JSON5 Formatter & Validator
This JSON5 tool parses the relaxed dialect of JSON that config files tend to use — comments, unquoted keys, single-quoted strings, trailing commas, hexadecimal numbers and explicit Infinity and NaN — and reports the first error with its line and column when something is wrong. It also converts to strict JSON for consumers that only speak the standard. That conversion loses things by necessity: comments have no JSON syntax at all, and Infinity and NaN have no representation, so they become null. Everything else translates cleanly.
How it works
JSON5 is JSON with the parts people keep wanting: comments, unquoted keys, single-quoted strings, trailing commas, hexadecimal numbers, leading and trailing decimal points, and explicit +Infinity and NaN. Paste JSON5 here and it is parsed and reported on; invalid input gets the line and column of the first problem.
Convert to strict JSON when the document has to be read by something that only speaks JSON — comments and the relaxed syntax are dropped, because none of it survives the conversion.
How to validate and convert JSON5
- Paste your JSON5 into the input on the left.
- A banner confirms it parses, or reports the first error with its position.
- Choose strict JSON or formatted JSON5 as the output, then copy or download.
What JSON5 adds to JSON
- Comments, both
//and/* */. - Unquoted object keys, when they are valid identifiers.
- Single-quoted strings, and strings broken across lines with a trailing backslash.
- Trailing commas in objects and arrays.
- Hexadecimal numbers, leading and trailing decimal points, and explicit
+InfinityandNaN.
Converting to strict JSON loses things
Comments are the obvious casualty — JSON has no syntax for them, so they cannot survive. Infinity and
NaN have no JSON representation either and become null. Everything else translates
cleanly: keys get quoted, single quotes become double quotes, trailing commas are dropped and hexadecimal numbers
are written in decimal.
Where JSON5 is used
Mostly in configuration files, where being able to explain a setting in a comment is worth more than strict
interoperability. Several build tools accept it, and tsconfig.json uses a similar relaxed dialect.
For data on the wire, strict JSON remains the right choice.
Frequently asked questions
What does JSON5 add to JSON?
Comments in both styles, unquoted object keys, single-quoted strings, strings broken across lines, trailing commas, hexadecimal numbers, leading and trailing decimal points, and explicit +Infinity and NaN.
What is lost converting JSON5 to strict JSON?
Comments, because JSON has no syntax for them, and Infinity and NaN, which have no JSON representation and become null. Keys get quoted, single quotes become double, trailing commas are dropped and hex numbers are written in decimal.
Where is JSON5 actually used?
Mostly configuration files, where explaining a setting in a comment matters more than strict interoperability. Several build tools accept it, and tsconfig.json uses a similar relaxed dialect.
Should I use JSON5 for API responses?
No. Strict JSON is what every client and library expects on the wire. JSON5 is for files a person edits by hand.
Is my document uploaded?
No. Parsing and conversion run entirely in your browser.
Related tools
JSON Formatter & Beautifier
This JSON formatter beautifies minified or messy JSON online with clean indentation, line numbers, and code folding.
JSON Validator
This JSON validator checks syntax instantly and pinpoints the exact line and column of any error.
YAML to JSON Converter
This YAML to JSON converter parses YAML into JSON online, supporting anchors, aliases, and multi-document files.