Compare
JSON5 vs JSON
JSON5 keeps JSON's data model while adding hand-editing conveniences such as comments, identifier keys, single-quoted strings, trailing commas, and hexadecimal numbers. Standard JSON uses stricter syntax and is widely supported by APIs and general-purpose parsers.
Which format should you choose?
Consider JSON5 for human-edited configuration only when every consumer supports it. Use JSON for APIs, standard parsers, and broad interoperability.
Good fit for JSON5
Hand-edited configuration files · Structured data with comments
- Readable data when the parser supports JSON5
- App settings with confirmed JSON5 support
Good fit for JSON
Web APIs, configuration files, and data exchange
- Transferring structured data
Basic information
| Field | JSON5 | JSON |
|---|---|---|
| Extension | .json5 | .json |
| MIME type | application/json | application/json |
| Common uses | Hand-edited configuration files · Structured data with comments | Web APIs, configuration files, and data exchange |
| How to open | Requires a JSON5-aware parser or tool | Open it in a text editor, IDE, or JSON-aware viewer. |
| Export or convert | Open it with an editor or parser that explicitly supports JSON5. A standard JSON parser may fail on comments, trailing commas, or other JSON5-only syntax. | Applications or conversion tools can convert it to formats such as CSV. |
Choose by use case
Readable data when the parser supports JSON5
Hand-edited configuration files · Structured data with comments
JSON5App settings with confirmed JSON5 support
Hand-edited configuration files · Structured data with comments
JSON5Transferring structured data
Web APIs, configuration files, and data exchange
JSONKey point 1
JSON5 accepts comments, single quotes, unquoted identifier keys, trailing commas, hexadecimal values, and Infinity/NaN syntax. These are not part of RFC 8259 JSON grammar and may be rejected by standard JSON parsers.
More on the differencesKey point 2
JSON5 is a syntactic superset with the same basic object, array, string, number, boolean, and null data model, but requires a JSON5-capable parser. Do not infer compatibility from a filename or media type.
More on the differencesMore on the differences
Choose JSON5 when comments and relaxed syntax improve hand-maintained settings and all tools explicitly parse JSON5. Choose JSON for communication and generic interchange. When converting, decide how non-JSON numbers are represented and verify that output is strict JSON.
- A standard JSON parser may reject otherwise valid JSON5 text. Check the exact parser, editor, build tool, or API consumer.
- Conversion to JSON loses comments and formatting intent. Infinity and NaN have no direct JSON number representation, so any replacement is application-specific.
- Test duplicate-key handling, number range and precision, character encoding, parser limits, and the final JSON conformance after conversion.
Frequently asked questions
Can I send a JSON5 file to any JSON API?
Not safely. JSON5 allows syntax outside standard JSON. Parse it with a JSON5-aware tool and serialize strict JSON if the API expects RFC 8259 JSON.