You’ve probably been burned by this: add a // temporary comment to your config, and the browser’s JSON.parse throws Unexpected token /. That’s not a JSON bug, it’s actually JSON5 syntax, and browsers only understand strict JSON. This post walks through the core differences between JSON and JSON5, and how the Piick JSON formatter uses tolerant mode to keep both formats working.
What exactly is the difference between JSON and JSON5?
JSON is a subset of JSON5. JSON5 relaxes 6 rules on top of standard JSON:
- Supports
//single-line comments and/* */block comments - Strings can use single quotes, not just double quotes
- Objects and arrays may have a trailing comma
- Keys can be unquoted (as long as they are valid identifiers)
- Numbers support hexadecimal (
0x1A),Infinity, andNaN - Strings may span multiple lines (line separators are inserted as line breaks)
Standard JSON rejects every one of these. The rule set was originally proposed by JSON’s creator Douglas Crockford, and was later formalized as the JSON5 standard. But as of today, the browser’s built-in JSON.parse still only accepts strict JSON — the spec moved on, but engines didn’t.
What real problems does JSON5 solve?
The two biggest pain points are comments and trailing commas. Config files need a few lines of comments to explain field meanings; standard JSON forbids them. With Git diffs, adding or removing a trailing comma shakes up the entire block (every new entry changes two lines). package.json doesn’t directly use JSON5 because the npm toolchain only accepts strict JSON. But your own config files, mock data, and drafts can absolutely use JSON5 — just convert back to strict JSON at the end with a tool.
Why isn’t the browser’s native JSON.parse enough?
JSON.parse() only understands spec-compliant JSON. Comments, single quotes, and trailing commas immediately throw a SyntaxError, and the error message just says Unexpected token without telling you the line and column. Debugging means binary search. In the Piick JSON formatter, tick the tolerant mode toggle and the tool will automatically strip comments, convert single quotes to double quotes, and remove trailing commas before formatting as standard JSON.
How Piick uses tolerant mode to cover both worlds
The whole pipeline runs locally in your browser — data never leaves your device:
- Paste your JSON5 string into the input box
- Toggle on tolerant mode
- Click “Format” — the tool first converts JSON5 to standard JSON, then outputs with 2-space, 4-space, tab, or minified indent
- Errors display precise line and column numbers, no binary search needed
- Copy the result with one click and paste it into any strict JSON parser
In short: tolerant mode lets you write JSON5’s way, deliver JSON’s way — both sides happy. Next time you write mock data, you won’t have to fight trailing commas anymore.
Open the Piick JSON formatter now and try tolerant mode. Paste a JSON5 draft straight in and see the result.