JSON5 Formatter
Format JSON5 — JSON with comments, unquoted keys, single quotes and trailing commas — into clean, consistently indented JSON5. Syntax errors are reported. Runs in your browser.
Suggested tools
About JSON5 Formatter
JSON5 Formatter reads JSON5 — the friendlier superset of JSON that allows comments, unquoted keys, single-quoted strings, trailing commas, hexadecimal numbers and Infinity/NaN — and writes it back with clean, consistent two-space indentation.
JSON5 is used in config files such as Babel and some build tools. If the input contains a syntax error, the message explains what is wrong and where. Everything runs locally in your browser — the text you paste is never uploaded.
How to use JSON5 Formatter
- Paste your JSON5 or upload a file.
- Press Beautify.
- Copy or download the formatted JSON5.
Key features
- Accepts comments, unquoted keys and trailing commas
- Clean two-space output
- Clear error messages with positions
- Uses the reference json5 library
Example
The comment is dropped and the layout is re-indented in JSON5 style.
{
// server settings
host: 'localhost',
port: 8080,
debug: true,
}{
host: 'localhost',
port: 8080,
debug: true,
}When to use JSON5 Formatter
- Tidying JSON5 configuration files with comments and unquoted keys.
- Checking and normalising config files written by hand.
- Converting messy JSON5 into a consistent style before committing.
Tips and common problems
- Comments are removed when formatting — keep the original if they matter.
- Plain JSON is valid JSON5, so you can format JSON here too.
- Use JSON5 Validator if you only want to check a file without changing it.
Frequently asked questions
No. The JSON5 is parsed into data and written out again, and comments are not part of the data, so they are removed. Keep your original if the comments matter.
Format it here, then paste it into JSON Formatter — or simply quote keys and remove comments. Valid JSON is already valid JSON5.
JSONC (used by VS Code) is JSON plus comments. JSON5 goes further, adding unquoted keys, single quotes and more. JSONC files are valid JSON5.