JSON Formatter

Format, validate & beautify JSON data instantly.

Paste JSON and click Format...

Format, Validate, Minify — One Paste

Paste any JSON into the left pane and click Format: the tool parses it with the browser's native JSON.parse and re-serializes it with 2-space indentation. Because parsing happens first, formatting doubles as validation — invalid input never produces half-formatted output, it produces the parser's exact error message instead. Click Minify to go the other way: all insignificant whitespace is stripped, which is what you want before shipping a payload or embedding JSON in a config.

A one-line API response like {"user":{"id":42,"name":"Ada","roles":["admin","dev"]}} becomes a readable, indented tree in one click — and minifies back to 52 characters when you're done inspecting it.

Reading the Error Messages

When validation fails, you see the real JavaScript parser error, usually with a position. The most common culprits:

Broken inputWhy it fails
{'key': 'value'}JSON requires double quotes, never single quotes
{"key": "value",}Trailing commas are invalid in JSON (unlike JavaScript)
{key: "value"}Keys must be quoted strings
{"n": 01}Leading zeros are not allowed in JSON numbers
{"note": undefined}undefined, NaN and comments don't exist in JSON

If you're pasting from a JavaScript file, remember JSON is a stricter subset: no comments, no trailing commas, no unquoted keys.

Pretty vs. Minified — When to Use Which

  • Formatted (2-space): debugging API responses, code review, config files humans edit, documentation examples.
  • Minified: production payloads, environment variables, HTTP request bodies — whitespace is pure overhead on the wire.

Minifying only removes whitespace between tokens; strings and values are untouched, so the data is byte-for-byte semantically identical.

Your Data Stays on Your Machine

Everything runs entirely in your browser — nothing is sent to a server, so it's safe to paste API keys, tokens, or customer data that happens to be inside a JSON blob. For converting JSON to spreadsheet-friendly formats, try the JSON to CSV converter; to compare two versions of a JSON file, use the diff checker.

Frequently Asked Questions

What does the JSON formatter do?
It parses your input with the native JSON parser and re-serializes it with 2-space indentation. Parsing first means it also validates: invalid JSON shows the exact syntax error instead of formatted output.
Can it minify JSON?
Yes. The Minify button strips all insignificant whitespace, producing the most compact valid representation — ideal for production payloads and config values.
Why does my JSON fail validation?
The usual suspects are single quotes instead of double quotes, trailing commas, unquoted keys, or comments. JSON is stricter than JavaScript object syntax — none of those are allowed.
Does formatting change my data?
No. Only whitespace between tokens changes. Keys, values, and their order pass through JSON.parse/JSON.stringify unchanged, so the result is semantically identical.
Is my JSON data safe to paste here?
Yes. All processing happens locally in your browser — your JSON is never sent to any server, so pasting payloads with tokens or personal data is safe.