Good to know
The rules JSON follows
JSON is defined by RFC 8259. It is stricter than JavaScript:
- Keys and strings use double quotes, never single quotes.
- No comma after the last item in an object or array.
- No comments, no
undefined, noNaNorInfinity. - Line breaks and tabs inside a string must be written as
\nand\t. - Numbers cannot have leading zeros (
007) or a leading plus sign.
Reading an error
When parsing fails, the tool walks through the text and reports where it stopped making sense. Lines and columns are counted from 1. For example:
{"a": 1,}is reported as invalid at line 1, column 9, because a trailing comma is not allowed before }. The position points to the first character that cannot be right, so the real mistake is sometimes just before it, such as a missing comma at the end of the previous line.
Big numbers stay exact
JavaScript normally stores numbers as 64-bit floating point, which is exact only up to 253 (9,007,199,254,740,992). An ID such as 12345678901234567890 would quietly become 12345678901234567000. In current browsers that support JSON.rawJSON, this tool keeps every number exactly as written, including 1.0 and very long decimals. Older browsers fall back to normal rounding.
Other details
- Sorting uses character code order, so capital letters come before lowercase:
Apple,Zed,banana. Nested objects are sorted too; arrays keep their order. - If a key appears twice in one object, only the last value is kept. RFC 8259 says keys should be unique for this reason.
- Minified size is reported in bytes of UTF-8, which is what a server will send.
- Very large files work but can be slow, since the text is parsed and laid out in your browser’s memory.