JSON Formatter

Free JSON Formatter & Validator

Format messy JSON into readable output, minify it back down, and get the exact line of any syntax error. Nothing uploaded.

Parsed by your browser's own JSON engine. Nothing is uploaded — safe for data you would not paste into a random website.

Last updated 3 September 2026

Why valid JavaScript isn't always valid JSON

JSON looks like a JavaScript object, which is exactly why it trips people up. JSON is stricter: keys must be in double quotes, strings must use double quotes rather than single, and a trailing comma after the last item — perfectly fine in modern JavaScript — is a syntax error.

Those three rules account for most of the errors this tool reports, and for all of them your browser can name the exact line and column, so you can go straight to the character that broke it. A few rarer token errors can't be pinned to a position — in those cases you get the browser's own message with the offending snippet quoted, rather than a made-up line number.

Format or minify

Format re-indents the data with two spaces per level, which is what you want while reading or debugging. Minify strips every space and newline outside of strings, producing the smallest valid version — useful when the JSON is going over a network and size matters. Both confirm the JSON is valid as a side effect.

The rules that catch people out

JSON is deliberately stricter than JavaScript object syntax, and most parse errors come from four specific rules. Keys must be in double quotes — single quotes are invalid, and unquoted keys are invalid even though both work in JavaScript. Trailing commas after the last item in an object or array are not allowed. Comments are not permitted in any form. And NaN, Infinity and undefined are not valid values, which is why serialising certain JavaScript objects produces output that will not parse back.

Because a parser reports the position where it noticed the problem rather than where the problem was introduced, the reported line is often after the real cause. A missing closing brace halfway through a large file typically produces an error at the very end. Formatting the document first makes the structure visible and usually reveals the mismatch faster than reading the error message does.

Minifying, and what it is for

Formatting adds indentation and line breaks so a human can read the structure. Minifying strips every optional space and newline, which for a large API payload can cut the transferred size by 20% or more. Both represent exactly the same data — no parser cares about the whitespace, so the choice is purely about who is reading it.

The sensible workflow is to minify what travels over the network and format what a person needs to inspect. One caution when formatting sensitive data: an API response often contains tokens, personal details or internal identifiers. Anything pasted into a hosted formatter is sent to that service, which is the reason this one runs entirely in your browser and transmits nothing.

Common questions

What are the most common JSON syntax errors?

A trailing comma after the last item, single quotes instead of double quotes, unquoted keys, and missing closing braces or brackets. JSON is stricter than JavaScript object syntax, so valid JavaScript is not always valid JSON.

What does minifying do?

It strips every space, tab and newline that is not inside a string, producing the smallest valid version of the same data. Useful for reducing payload size when sending JSON over a network.

Is my JSON sent to a server?

No. Parsing and formatting happen entirely in your browser using the built-in JSON parser. Nothing is uploaded, logged or stored, which matters if the data contains anything sensitive.

Why is my JSON invalid when it looks fine?

The four usual causes are single quotes instead of double quotes around keys or strings, a trailing comma after the last item, comments, and values such as NaN or undefined. All four are legal JavaScript but invalid JSON.

Why does the error point to the wrong line?

A parser reports where it detected the problem, not where it began. A missing closing brace early in a file usually surfaces as an error at the very end. Formatting the document first makes the structure visible and locates the mismatch faster.

What is the point of minifying JSON?

It removes all optional whitespace, which can cut the transferred size of a large payload by 20% or more. The data is identical — parsers ignore whitespace entirely — so minify what travels over the network and format what a person needs to read.

The other tools