What is a JSON Formatter?
A JSON formatter does two jobs: it checks that a document parses, and it re-writes it with indentation so a human can read it. This one runs both through the browser's own `JSON.parse`, so the validator is the same parser that will read the file in production, not a reimplementation.
JSON is defined by RFC 8259 and is stricter than JavaScript object syntax. Keys must be double-quoted, comments are not allowed, trailing commas are a syntax error, and the only values are objects, arrays, strings, numbers, `true`, `false` and `null`. Those four restrictions cause almost every “invalid JSON” message people hit.
Formatting is purely cosmetic: the parser reads the document into memory and the formatter writes it back out. That means key order is preserved as written, duplicate keys collapse to the last one, and numbers are stored as IEEE 754 doubles — which is why a 20-digit identifier can come back with its tail changed.
How to format or validate JSON
- Paste the JSON into the box. The byte and line counts underneath update as you type.
- Choose an indent: two spaces is the common style, four suits some editors, and a tab matches Go-style projects.
- Press Validate to check the syntax without changing the text, or Format to pretty-print it.
- If it fails, read the parser message — it names the character position where parsing stopped, which is usually a few characters after the real mistake.
- Press Copy to take the formatted or minified result, then paste it into your editor or your request body.
JSON Formatter limits and rules
| Item | Limit |
|---|---|
| Standard | RFC 8259 — no comments, no trailing commas, double-quoted keys only |
| Indent | Two spaces, four spaces or one tab |
| Key order | Preserved as written; keys are never sorted |
| Duplicate keys | Collapsed — the last occurrence wins, silently |
| Number precision | IEEE 754 doubles; integers beyond 2^53 lose their exact value |
| Minify | Removes whitespace between tokens, nothing else |
| Beyond JSON | JSON5, JSONC, JSON Lines and NDJSON are rejected as invalid |
| Size | Bounded by browser memory — tens of megabytes parse, hundreds may not |
When to use it
- Reading a minified API response that arrived as one long line.
- Finding the exact character where a hand-edited config file broke.
- Shrinking a fixture before committing it, so the diff stays reviewable.
- Checking whether a file with a trailing comma is JSON or JavaScript — this tool will tell you it is not JSON.
- Producing a consistent two-space version of a file that was formatted by three different editors.
Is it private?
Everything runs inside your browser. Your text and files are never uploaded, never stored and never seen by anyone else — including me. You can use the tool with the network tab open and watch no request leave the page. Closing the tab erases the input.
Frequently asked questions
Because the specification does not include them. JavaScript allows both, and YAML and JSON5 add them, so it is easy to assume JSON does too. A parser that accepts them is not a JSON parser, and a document that relies on them will fail in the next tool that reads it.
The parser reached a `}` where it expected another value or a key. The usual causes are a trailing comma before the brace, a missing value, or an extra comma between entries. The position is where parsing stopped, so look at the character just before it.
Because JSON numbers are read as IEEE 754 doubles, which hold about 15–17 significant digits. A 20-digit ID like `12345678901234567890` is rounded when parsed and written back differently. Keep such identifiers as strings in the source data.
Not the values, but it can change what you see: duplicate keys collapse to the last value, and number formatting is normalised (`1e3` becomes `1000`). Key order is preserved. If you need the exact original bytes, keep a copy — pretty-printing is not byte-preserving.
Only before compression. Minifying removes whitespace, which gzip or Brotli would have removed anyway, so a minified and a pretty-printed response compress to nearly the same size. Minify for logs and diffs, not as a substitute for HTTP compression.
No. Parsing and re-serialising happen in the page with the built-in JSON parser. No request is made, nothing is stored, and the tool keeps working offline — which is why it is safe for payloads that contain tokens.
Related tools
Written and maintained by Md. Nur Hossain Repon.