JSON Formatter

Pretty-print, validate, or minify any JSON payload using the browser's native parser. Paste in a blob of JSON, choose your indentation, and get a cleanly-formatted output with clear error messages when something's malformed. Nothing is sent to a server — safe for API responses, auth tokens, and config files.

Quick answer

Paste JSON above, pick an indent (2 spaces, 4 spaces, tab, or minified), and click Format. Uses native JSON.parse and JSON.stringify. All processing happens in your browser.

JSON Formatter & Validator

How the JSON formatter works

The tool uses the browser's built-in JSON.parse() to convert your input string into a JavaScript object, then JSON.stringify() to serialize it back out with your chosen indentation. These are the same APIs that Node.js, every major browser, and the JSON spec all use, so if the formatter accepts it, any JSON parser will accept it. If the parser throws, the error message from the browser (typically the line and column of the offending character) is displayed verbatim.

JSON is a strict subset of JavaScript object literals. Keys must be double-quoted. Strings must use double quotes (not single). Trailing commas are forbidden. Comments are not allowed. Only seven value types are permitted: string, number, boolean, null, object, array, and nothing else. If you paste something that looks like JSON but is actually a JavaScript object literal, expect a parse error.

When to use it

Pretty-print API responses you're debugging, validate a JSON config file before committing it, minify a JSON payload for production, or hunt down the "unexpected token" that's crashing your Python / Node / Go parser. It's also useful for comparing two JSON blobs — format both with the same indentation and the structural differences jump out immediately.

Because this runs entirely in the browser, it's safe for sensitive data: auth tokens, API keys, user PII, customer records. Paste it in, format it, close the tab. Nothing is sent to a server, logged, cached, or stored anywhere.

Common mistakes

Frequently asked questions

Is this JSON formatter secure?

Yes. Everything runs in your browser using native JSON.parse and JSON.stringify. No data is sent to a server — safe for auth tokens, API keys, and user PII.

What's the difference between JSON and JavaScript object literals?

JSON requires double-quoted keys, forbids trailing commas, and doesn't allow comments, undefined, or functions. JavaScript is more permissive.

How do I find a syntax error in JSON?

Paste the JSON into the formatter. If it fails, the error message includes line and column. Most common: trailing commas, unquoted keys, or single quotes.

How do I minify JSON?

Choose "Minified" as the indent option. This removes all whitespace from the output for the smallest valid JSON string.

Can I format JSON5 or JSONC?

Not directly. JSON5 (with comments, unquoted keys, trailing commas) and JSONC (JSON with comments) require a different parser. Remove the non-standard features first.

Related tools