What Is a JSON Formatter?
JSON is the format almost every web API speaks, and almost every API sends it minified — one long line with the whitespace stripped out to save bandwidth. That is efficient for machines and unreadable for people. A JSON formatter re-indents that string so the nesting becomes visible, and validates it along the way: if a comma is missing or a bracket never closes, you get the position of the fault instead of a blank screen. This one runs on the page you are already looking at, so the payload you paste — which often carries tokens, internal IDs or customer records — is never uploaded anywhere.
Why your JSON won't parse
Almost every parse failure comes from one of a handful of causes. If the formatter rejects your input, work down this list before anything else — the error position it reports is the character where the parser gave up, which is often one token after the actual mistake.
A trailing comma before } or ]
{"a": 1, "b": 2,} is valid JavaScript and invalid JSON. This is the single most common failure, because editors and hand-written config files accumulate them during edits. The reported error lands on the closing brace, not on the comma — look one character back.
Single quotes instead of double
JSON only accepts double quotes, for both keys and string values. {'name': 'test'} fails; {"name": "test"} parses. This usually happens when a JavaScript object literal is pasted straight from source code, where single quotes are perfectly legal.
NaN, Infinity or undefined as values
These exist in JavaScript but are not part of the JSON specification, so JSON.stringify silently turns undefined into nothing and NaN into null. If you are hand-editing a payload, replace them with null or a sentinel value — a literal NaN in the text will not parse back.
Unquoted or duplicated keys
Every key must be a quoted string: {name: "test"} is invalid. Duplicate keys are worse because they do parse — {"id": 1, "id": 2} is accepted and the last one silently wins, so a copy-paste mistake becomes a data bug rather than a syntax error.
An invisible character at the very start
A file saved as UTF-8 with BOM begins with a byte-order mark the parser sees as garbage before the opening brace, producing an error at position 0 on JSON that looks perfect. The same applies to a stray non-breaking space copied from a web page or a chat client.
How It Works
The formatter parses your input using the browser's native JSON.parse(), which validates the structure and builds an in-memory object. It then serialises that object back to a string with JSON.stringify(obj, null, 2) — the third argument sets the two-space indentation. Because parsing happens first, any syntax error (missing comma, trailing comma, unquoted key) is caught and reported before formatting begins.
Minification works the same path in reverse: parse first, then serialise with no spacing. This guarantees the output is always valid and semantically identical to the input.
Formatting Your JSON
- Paste your raw or minified JSON string into the input editor on the left. You can also type JSON directly if you are creating or testing a new structure.
- Click the Format button to validate and prettify your JSON. If valid, the formatted output appears with correct indentation and is easy to copy or share.
- If there are any errors — such as missing commas, unclosed brackets, or incorrect data types — a clear error message will pinpoint the issue. Fix the problem and click Format again to revalidate.
JSON Stays in Your Browser
Your JSON is formatted and validated using JavaScript running on your machine. The JSON data you paste is processed entirely locally — it never reaches our servers or any external service.