JSON5 formatter
Format and validate JSON5 in the browser: comments, trailing commas, single quotes and unquoted keys; output standard JSON or JSON5 (with comments re-attached to their keys), and get exact line/column errors.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
What this tool does
- Format JSON5 config files — comments, trailing commas, single quotes, unquoted keys — and emit either standard JSON or JSON5 again.
- Validate JSON5 syntax with line, column and a reason (illegal character, bad escape, unescaped control character, malformed number) instead of guessing where it broke.
- Keep the comments from a config file: with comment preservation enabled, end-of-line comments stay on their line and standalone comments are placed above their key.
- Emit standard JSON to strip all the JSON5 leniency (comments, trailing commas, unquoted keys, single quotes) so any JSON parser can read it.
Example
Input
// UniKit 示例
{
name: 'UniKit', // 名称
version: 2, /* 版本 */
tags: ['json5', 'format',],
}Output
{
// UniKit 示例
name: "UniKit", // 名称
version: 2, /* 版本 */
tags: [
"json5",
"format",
],
}This is JSON5 + format + keep comments: single quotes become double quotes and trailing commas survive in JSON5 output (standard JSON output drops them).
Frequently asked questions
How does JSON5 differ from standard JSON?
JSON5 allows comments (// and /* */), trailing commas, single-quoted strings, unquoted object keys, hex numbers, a leading +, .5 and 5. decimals, and multi-line strings. Standard JSON allows none of that, so switch to standard JSON output when feeding another system.
How are comments re-attached to their keys?
The source is scanned for comments and nearby keys: an end-of-line comment is bound to the key before it, a standalone comment to the key after it. Those anchors are then located in the formatted output. Comments that match no key end up at the bottom of the file.
What happens to Infinity and NaN in standard JSON output?
JSON5 accepts Infinity, NaN and +Infinity literals, but standard JSON has no such values and JSON.stringify writes them as null. Use JSON5 output if you need to keep them.
What is the difference between format and minify?
Formatting produces multi-line output with the indent you picked (2 or 4 spaces, or tabs). Minifying squeezes everything onto one line for environment variables or smaller payloads; comments are not kept and the indent option does nothing.
Is my content uploaded anywhere?
No. Parsing and formatting run entirely in your browser, with no network requests, and it works offline.
Keywords:json5json5 formatterjson5 格式化json5 校验json5 validatorjson5 parser注释 jsoncommentstrailing comma尾逗号单引号unquoted keys