JSON Formatter — Free Online Tool on Toolpile
Every tool you need, one place
PDF, Image, AI, Dev, and Business tools — free, private, no signup.
Toolpile uses cookies for analytics and ads. The tools themselves keep your files in the browser — that doesn't change. Read the full policy
PDF, Image, AI, Dev, and Business tools — free, private, no signup.
About JSON Formatter
A JSON formatter's job isn't to pretty-print — it's to help you read, debug, and ship JSON that other systems will actually accept. The buttons do the obvious work; what follows is the context most of us learned the hard way.
JSON has no canonical whitespace rule. `{"a":1,"b":2}` and `{ "a": 1, "b": 2 }` are byte-different but semantically identical — parsers return the same object either way. So 'beautify' is purely for human readers: indent 2 or 4 spaces, newlines after commas, keys on their own lines. 'Minify' strips all that whitespace for transport (a 2MB prettified response usually compresses to <500KB minified, which cuts first-byte latency on slow links).
The most common JSON frustration isn't formatting at all — it's strict-mode violations. JSON forbids trailing commas, unquoted keys, single quotes around strings, JavaScript-style comments, `undefined`, and `NaN`/`Infinity` as number values. Most valid-looking data that won't parse has one of those six issues. A formatter that merely indents won't flag them; one that validates will. This tool validates on every change and highlights the exact character position where parsing breaks, which is usually the fastest way to find a stray comma.
JSON5 and JSONC (the superset that VS Code's settings files use) relax several of those rules: trailing commas, comments, and unquoted keys are allowed. They are NOT JSON, and sending JSON5 to a strict parser will fail. If your API works in your editor but breaks in production, that's almost always what happened.
Unexpected token at position N
Parser hit a character it didn't expect. 99% of the time it's a missing closing quote or bracket earlier than where the error says — the position is where the parser gave up, not where you went wrong. Scroll back from that position looking for unbalanced brackets.
Unterminated string at position N
You have an open quote that never closed. Often caused by a literal newline inside a string — JSON strings can't contain raw newlines; use \n. If you're copying from a log file, the newlines came along for the ride.
Duplicate keys are allowed but...
JSON spec technically allows duplicate keys in an object; the behavior is parser-defined. Most parsers take the LAST occurrence. So `{"a":1,"a":2}` parses to `{a:2}` in JavaScript, Python, and Go, but some legacy parsers throw. Don't do it.
Numbers that look fine but fail
JSON numbers can't have leading zeros (`007` is invalid, `0` and `-0` are fine) and can't use hex or octal notation (`0x1F` is invalid). Integer max precision is ~2^53 in JavaScript-style parsers — anything larger silently loses precision unless you quote it as a string.
Is JSON case-sensitive?
Keys yes, `true`/`false`/`null` must be lowercase, and Unicode-normalization matters. `'\u00e9'` and `'é'` are the same character but different byte sequences; some parsers normalize, others don't.
Is my JSON sent to a server?
No. All parsing, formatting, and minification runs in your browser via the native JSON API and JavaScript — zero network requests, even if the JSON contains API keys or PII. You could use this tool offline after first load.
Why does minified JSON still have 'extra' whitespace?
Inside JSON strings, spaces are significant data. A minifier can't strip them without corrupting the content. If your minified output looks 'loose', that whitespace is inside string values.
Does it sort keys?
Not by default — JSON technically has no ordering guarantee, so many APIs care about receiving keys in a specific order. Sorting is off to avoid silently breaking requests. If you need deterministic output for diff purposes, copy the result into a sort-keys-enabled tool.
Can it handle really large files?
Up to about 50MB reliably. Above that, browser memory becomes the constraint — the native `JSON.parse` allocates the full parse tree in memory. For multi-GB logs, stream-parse on the server instead.
What about JSONC / JSON5?
This formatter is strict JSON. It will flag JSONC-style comments and trailing commas as errors. If you need to convert JSONC to JSON, strip the comments yourself (or use a JSONC-aware library); the strict parser will then accept the result.
Related tools