JSON Formatter
Pretty-print, minify, and validate JSON with precise error positions and a tree view.
Settings
How JSON Formatter works
JSON has a deliberately small grammar: objects, arrays, strings, numbers, true, false, and null. Formatting parses your text into that structure and re-serialises it with consistent indentation, which means a successful format is also a proof of validity — malformed JSON cannot be pretty-printed.
When parsing fails, the position of the failure is the useful part. A parser reports where it could no longer proceed, which is typically just after the real mistake: a trailing comma before a closing brace, an unquoted key, a single-quoted string, or an unescaped control character inside a string.
Minifying removes every byte that carries no meaning — whitespace between tokens, newlines, and indentation. Structure and values are untouched, so a minified document parses to exactly the same data. On a large API response this routinely cuts 20–40% of the size before compression.
The tree view renders the parsed structure as collapsible nodes rather than text, which is how you navigate a deeply nested response without counting brackets. Formatting also normalises key order only where you ask it to; by default JSON object key order is preserved as written, since the specification treats objects as unordered but every real implementation keeps insertion order.
Reference
- Valid types: object, array, string, number, true, false, null
- No comments, no trailing commas, no single quotes, no unquoted keys
- Strings must be double-quoted; \ " and control characters below U+0020 must be escaped
- Numbers follow JSON grammar: no leading +, no leading zeros, no NaN or Infinity
How to use this formatter
Paste your JSON
Drop in an API response, a config file, or a log line. Size is not limited by the tool.
Read the validation result
Valid input formats immediately; invalid input reports the exact line and column where parsing failed.
Choose format or minify
Pretty-print with your preferred indent for reading and diffing, or minify for transport and storage.
Explore with the tree view
Switch to the tree to collapse branches and find the field you need in a deeply nested document.
Worked examples
The trailing comma
- Given
- {"a": 1, "b": 2,}
- Result
- Parse error at the closing brace
Legal in JavaScript, illegal in JSON. The error points at the brace because that is where the parser gave up, not where you typed the comma.
Single quotes
- Given
- {'name': 'alice'}
- Result
- Parse error at position 1
JSON requires double quotes for both keys and string values. This is the most common paste-from-Python or paste-from-JS mistake.
Minification savings
- Given
- A 48 KB pretty-printed API response
- Result
- 31 KB minified — 35% smaller
Identical data. Combined with gzip the absolute saving shrinks, but it is free and costs nothing at runtime.
When to use it
- Making an unreadable single-line API response legible while debugging.
- Finding the exact position of a syntax error in a hand-edited config file.
- Minifying a payload before embedding it in a request or a fixture.
- Navigating a deeply nested response with the collapsible tree instead of scrolling.
- Normalising formatting so two JSON documents produce a clean diff.
Things to watch out for
- JSON has no comments. Anything with // or /* */ is JSON5 or JSONC and will not parse as JSON.
- Numbers are IEEE-754 doubles once parsed, so integers beyond 2^53 lose precision. Transmit large identifiers as strings.
- Duplicate keys are not forbidden by the specification but behaviour varies; most parsers keep the last one. Avoid relying on it.
- NaN, Infinity, and undefined are not JSON values, even though JavaScript will happily produce them.
Frequently asked questions
Why does my JSON fail to parse when it looks correct?
The usual causes are a trailing comma before a closing brace or bracket, single quotes instead of double, unquoted object keys, comments, or an unescaped newline inside a string. The reported position is where the parser stopped, which is often just past the actual mistake.
Is my data sent to a server?
No. Parsing, formatting, minifying, and the tree view all run in your browser. Nothing you paste is transmitted, so production payloads are safe to inspect here.
Can JSON contain comments?
No. The specification has no comment syntax. Formats that allow them — JSON5, JSONC, YAML — are supersets or different languages, and a strict JSON parser rejects them.
Does minifying change my data?
No. It removes only whitespace that sits between tokens and carries no meaning, so the minified document parses to exactly the same values in the same structure. Whitespace inside a string literal is significant and is preserved untouched — only the formatting around the data changes.
Why did my large ID number change?
JSON numbers become IEEE-754 doubles, which represent integers exactly only up to 2^53 − 1. A 19-digit identifier will be silently rounded. The fix is to send such values as strings.
What indentation should I use?
Two spaces is the most common convention and keeps deeply nested documents narrow. Four is more readable at shallow depths. Tabs work but render inconsistently across tools — pick one and apply it repository-wide.
Related Developers tools
All developer tools- UUID Generator Generate one or thousands of v4 UUIDs and copy them all at once.
- URL Encoder / Decoder Percent-encode or decode URLs and query-string components.
- Regex Tester Test a JavaScript regular expression live — highlighted matches, capture groups, a replace preview, and a library of common patterns.
- QR Code Generator Turn text or URLs into crisp QR codes and download them as PNG or SVG.
- QR Code Reader Decode QR codes from an image, a drag-and-drop file, or your webcam.
- TOTP Generator Turn an authenticator secret or otpauth QR code into live one-time passwords, with a 30-second countdown and one-click copy.