JSON formatter and validator
Paste JSON to pretty-print it, minify it, or find out exactly where it stops being valid. Runs in your browser, so config files and API responses containing real data stay on your machine.
Runs in your browser — nothing is uploadedWhat JSON does not allow
Most "invalid JSON" is one of a handful of things borrowed from JavaScript that JSON never
permitted: a trailing comma after the last element, single quotes around strings or keys,
unquoted keys, comments, and the values NaN, Infinity and
undefined. JSON5 and JSONC allow several of these; strict JSON allows none.
The precision problem
JSON numbers have no defined precision, but nearly every parser reads them as IEEE-754 doubles.
Integers above 9,007,199,254,740,991 therefore lose precision silently: an ID of
9007199254740993 comes back as 9007199254740992. If your IDs are 64-bit, send them
as strings.
Depth and size
Recursive parsers overflow the stack on deeply nested input, which makes nesting a denial-of-service vector on any endpoint accepting JSON. Bound the depth and the body size before parsing, not after.
Questions
Why is my JSON invalid when it looks fine?
Almost always a trailing comma after the last item, single quotes instead of double, an unquoted key, or a comment. All four are valid JavaScript and none is valid JSON.
Can JSON have comments?
Not in strict JSON. JSONC and JSON5 add them, and many tools accept them in config files, but anything sent over an API should assume they are rejected.
Why did my large ID change value?
It went through a double. JavaScript numbers are IEEE-754, so integers above 2^53 - 1 cannot be represented exactly. Send 64-bit identifiers as strings.
Is my data uploaded anywhere?
No. The parsing and formatting happen in your browser. Nothing is sent to a server.