JSON Formatter
Pretty-print, minify and validate JSON, with errors pinpointed.
About this JSON formatter
Paste JSON and get it back properly indented, or minified down to the smallest valid form. If it does not parse, the error is reported with the exact line and column, which is the part that actually saves time β the raw browser message gives you only a character offset.
Alongside the result you get a count of keys, arrays and nesting depth, plus how many bytes minifying would save. Everything is parsed in the page, so API responses, tokens and customer data never leave your machine.
The JSON mistakes that cause almost every error
- Trailing commas.
{"a": 1,}is valid JavaScript and invalid JSON. This is the single most common cause. - Single quotes. JSON requires double quotes, on both keys and string values.
- Unquoted keys.
{name: "x"}is a JavaScript object literal, not JSON. - Comments. JSON has no comment syntax.
//and/* */both break it. - NaN, Infinity or undefined. None are valid JSON values. Use
null. - Smart quotes. Copying from a document or chat app can silently substitute curly quotes, which look almost identical and are not valid.
Frequently asked questions
Why does my JSON say 'Unexpected token'?
Almost always a trailing comma, a single quote where a double quote is required, an unquoted key, or a comment. The line and column shown above point at where the parser gave up, which is usually just after the real mistake.
Is my JSON data sent anywhere?
No. It is parsed by JavaScript in this page using the browser's built-in JSON parser. Nothing is uploaded or logged, which matters when you are debugging an API response containing real data.
What does minifying JSON do?
It removes all whitespace and line breaks, producing the smallest valid representation. The data is identical β it is only the formatting that changes. Useful for reducing payload size in transit or in a config value.
Can JSON have comments?
Not in standard JSON. Some parsers accept them as an extension (JSON5, JSONC), but anything strictly conformant will reject them. Put explanatory text in a regular key instead.