Format JSON5 to valid JSON
online, free & instant
Paste JSON with comments, trailing commas, or unquoted keys and get clean, standards-compliant JSON output. The repair engine handles all JSON5 extensions automatically.
Open JSON5 FormatterJSON5 to valid JSON in three steps
No account. No upload. No nonsense.
No Server
Your JSON never leaves your device. There is no backend to send it to.
Zero Dependencies
Single self-contained HTML file. No frameworks, no CDN calls, nothing to break.
Works Offline
Load once and use forever — even on a plane or without internet access.
Related JSON tools
Common questions answered
What is JSON5 and how is it different from JSON?
JSON5 is an extension of JSON that allows comments (// and /* */), trailing commas, unquoted keys, single-quoted strings, hex numbers, and multi-line strings. It is a superset — every valid JSON is also valid JSON5, but not vice versa.
Can I add comments to JSON files?
Standard JSON does not support comments, but JSON5 does. You can write JSON with // or /* */ comments, then use the Repair tab to strip them and produce valid JSON that any parser can read.
How does the JSON5 formatter handle trailing commas?
The repair engine automatically removes trailing commas from objects and arrays, converting relaxed JSON5 syntax into strict, valid JSON.
Does this tool convert unquoted keys to quoted keys?
Yes. The Repair tab detects unquoted object keys (a JSON5 feature) and wraps them in double quotes to produce standard JSON.
Is the JSON5 conversion done in my browser?
Yes, all processing happens 100% client-side. Your data never leaves your device — no server, no upload, works offline.
What is JSON5?
JSON5 is an extension of JSON that adds features from ECMAScript 5.1 to make it more human-friendly. JSON5 allows single-line and multi-line comments, trailing commas, single-quoted strings, unquoted object keys (when valid identifiers), hexadecimal numbers, and special values like Infinity and NaN. It was designed for configuration files where humans write and maintain JSON by hand.
This tool formats JSON5 input by normalizing it to standard JSON, then applying indentation and syntax highlighting. If you have a JSON5 configuration file (like a babel.config.json5), paste it here to get a clean, readable version. The output is strict JSON — comments and trailing commas are removed since they are not valid in the JSON specification.
{
// user config
name: 'Alice',
age: 30,
active: true,
}
{
"name": "Alice",
"age": 30,
"active": true
}
Get the most out of this tool
- Use JSON5 for configuration files that need comments — tools like Babel, ESLint, and Webpack support it natively.
- This formatter strips JSON5 extensions and outputs strict JSON — useful for converting config files to standard format.
- If your JSON5 uses trailing commas, the Repair tab also handles them without needing JSON5 mode.
Understanding JSON5 and its extensions to JSON
JSON5 was created in 2012 by Aseem Mital to address the pain points developers experience when writing JSON by hand. While standard JSON is an excellent machine-generated format, it becomes tedious for humans to author and maintain — particularly the prohibition on comments and trailing commas. JSON5 is a strict superset of JSON: every valid JSON document is valid JSON5, but JSON5 allows several additional syntactic conveniences that standard JSON forbids.
Single-line comments using // and multi-line block comments using /* ... */ are perhaps the most frequently missed feature of standard JSON. Configuration files written in JSON often need to document why a value is set, what a field means, or which environment a setting applies to. JSON5 comments fill this gap, enabling self-documenting configuration files that explain their own settings inline.
Trailing commas after the last item in arrays and objects eliminate a common source of JSON syntax errors. In standard JSON, adding a new item to the end of a list requires adding a comma to the previously final item, which shows up as a confusing diff entry. In JSON5, trailing commas are allowed, so each item can independently have a trailing comma — making list additions produce single-line diffs and making the format more version-control friendly.
Unquoted object keys are another JSON5 convenience. Standard JSON requires all keys to be double-quoted strings, even when they are simple identifiers. JSON5 allows ECMAScript 5 identifier names as unquoted keys: {name: "Alice"} instead of {"name": "Alice"}. Keys that are reserved words or contain special characters still require quoting, but simple alphanumeric keys can be written without quotes.
Single-quoted strings provide an alternative to double-quoted strings, which is familiar to developers coming from JavaScript, Python, or Ruby backgrounds where single and double quotes are interchangeable. JSON5 also supports multi-line string literals — a string can span multiple lines when each line continuation is marked with a backslash, avoiding the need to embed \n escape sequences for readable multi-line content.
Numeric extensions in JSON5 include hexadecimal literals (0xFF), IEEE 754 special values (Infinity, -Infinity, NaN), and an explicit positive sign for numbers (+1.5). Standard JSON cannot represent infinity or NaN, causing JavaScript's JSON.stringify(Infinity) to produce the string "null". JSON5 provides a standards-backed way to represent these values in data files.
The practical adoption of JSON5 has been significant: Babel uses it for babel.config.json5, ESLint accepts it for configuration, and VS Code uses a JSONC variant (JSON with comments) for its settings.json. The json5 npm package provides parsing and serialization for Node.js applications. However, JSON5 is not supported by language standard libraries — Python's json module and Go's encoding/json package only handle standard JSON, requiring explicit JSON5 parser libraries.
When developers use JSON5
JSON5 pitfalls and limitations
- Using JSON5 where standard JSON is required: APIs, JSON Schema validators, and language standard libraries only accept standard JSON. JSON5 files must be converted to standard JSON before use in these contexts. Never commit JSON5 files to a repo expecting tools to parse them as standard JSON without a build step.
- Assuming NaN and Infinity are supported everywhere: While JSON5 allows
NaNandInfinity, standard JSON does not. When converting JSON5 with these values to standard JSON, they must either be replaced with null, omitted, or converted to strings — decide which representation makes sense for your data before converting. - Forgetting that unquoted keys have restrictions: JSON5 unquoted keys follow ECMAScript identifier rules — they cannot start with numbers, cannot contain hyphens, and cannot be certain reserved words. A key like
my-fieldor2fastmust still be quoted. Check that all your unquoted keys are valid ECMAScript identifiers. - Not stripping comments before JSON parsing: If you try to parse a JSON5 file with a standard JSON parser, comments will cause a parse error. Always use a JSON5 parser library or strip comments during a preprocessing step before passing JSON5 content to standard JSON parsers.
Additional frequently asked questions
Is JSON5 an official standard?
JSON5 is not an IETF or ISO standard. It is a community-maintained specification published at json5.org. The specification is stable and widely implemented, but it is not recognized by standards bodies the way JSON (RFC 8259) is. For interoperability with external systems, always prefer standard JSON unless you control both the producer and consumer.
Which tools and languages support JSON5 natively?
The json5 npm package supports JSON5 in Node.js. Babel uses JSON5 for its configuration file. VS Code uses a JSONC (JSON with comments) variant for settings. Python, Go, and Java do not include JSON5 parsers in their standard libraries — you must add a third-party library. The json5 specification lists known implementations across languages at json5.org.
What is the difference between JSON5 and JSONC?
JSONC (JSON with Comments) is a subset of JSON5 that only adds comments to standard JSON, without the other JSON5 extensions like trailing commas, unquoted keys, or single-quoted strings. VS Code uses JSONC for its configuration files. JSON5 is a superset that includes JSONC features plus additional extensions. Most JSONC documents are also valid JSON5.
Can JSON5 be used for API request and response bodies?
No — HTTP APIs expect Content-Type: application/json bodies to be standard RFC 8259 JSON. JSON5 is not a recognized MIME type and most HTTP frameworks will reject JSON5 bodies. Use JSON5 only for local configuration files and data files where you control the parser. Convert to standard JSON before sending over HTTP.