JSON Formatter & Minifier (validates and pretty-prints)
Paste any JSON to format with 2/4/8 spaces of indentation, or minify to a single line. Invalid JSON shows a parse error so you can find the issue quickly.
{
"hello": "world",
"items": [
1,
2,
3
]
}How it works
What this tool does
JSON is a strict format — every quote, comma, and bracket has to be in the right place. Browsers and APIs return cryptic 'Unexpected token' messages when something is off, and the issue is often invisible at a glance. This formatter parses the input with the browser's native JSON parser, then re-serializes it pretty (with indent) or minified (no whitespace).
If parsing fails, you get the underlying error directly — usually with the position of the bad character. From there, you can find the missing comma, unescaped quote, or trailing comma quickly.
Format vs minify
Format with indent: the standard way to read JSON. 2 spaces is conventional in JavaScript-land; 4 spaces is common in Python and Java contexts. Pick whichever your project uses.
Minify: collapse to a single line with no whitespace. Useful when embedding JSON in URLs, environment variables, or anywhere whitespace matters. The size difference is meaningful: a typical pretty-printed config file shrinks 20-40% when minified.
Common JSON gotchas
Trailing commas. Allowed in JavaScript, not in JSON. {a:1, b:2,} parses in your code editor but fails when sent over the wire.
Single quotes. JSON requires double quotes for both keys and string values. {'a': 1} is invalid JSON. {"a": 1} is correct.
Comments. JSON has no comments. // or /* */ inside JSON breaks parsing. JSONC (used by VS Code config) supports comments but isn't standard JSON.
Numbers. JSON doesn't support NaN or Infinity. Use null, or wrap in a string, depending on your downstream consumer.
Frequently asked questions
›Does this support JSONC (JSON with comments)?
Not yet. Strip comments first or use a tool that supports JSONC.
›What's the size limit?
Modern browsers handle multi-megabyte JSON, though the textarea may slow down past ~1 MB. For huge files, use a desktop tool.
›Why is my JSON invalid?
Most often: a trailing comma, single quotes, or an unescaped quote inside a string. The parser error points at the column where the issue is detected.
›Can I sort keys alphabetically?
Not in this version. Pasting into a sort-aware tool (like jq with --sort-keys) is the cleanest path; we may add the option later.
›Does it handle deeply nested JSON?
Yes. The browser's JSON parser handles any practical depth.
›Why doesn't minify make a 1 MB file 1 byte?
Minify only removes whitespace. The actual data is still there. For real size reduction, gzip or use a binary format like MessagePack.
›Is the data sent anywhere?
No. All parsing and formatting happens in your browser.
›What about JSON Schema validation?
This tool validates syntax only. For schema validation, use a JSON Schema validator with your schema file.
Related tools
Last updated: