JSON vs JSON5: Differences, Examples, and When to Convert
JSON5 allows comments, trailing commas and unquoted keys. Learn the exact differences from strict JSON and when to convert back.
Advertisement
Standard JSON is strict by design. JSON5 is a friendlier superset created for configuration files — it relaxes the rules humans find annoying, at the cost of compatibility.
What JSON5 allows that JSON does not
- Comments —
// lineand/* block */. - Trailing commas —
{"a": 1,}is fine. - Unquoted keys —
{name: "Ada"}works. - Single-quoted strings —
{'a': 'b'}. - Extra number forms — hex,
Infinity,NaN, leading+. - Multi-line strings with escaped newlines.
Why this tool uses strict JSON
APIs, browsers and JSON.parse accept only strict JSON. That is why JSONora — like our formatter and validator — reports JSON5 as invalid: it would break the moment you send it to a real API.
When to use each
- Use strict JSON for APIs, data exchange and anything parsed by
JSON.parse. - Use JSON5 (or YAML) for hand-edited configs where comments help. Our JSON to YAML converter is often a better fit.
Converting JSON5 to JSON
Advertisement