JSON Formatter & Validator (browser only)
Paste JSON to pretty-print, minify, or validate it. Syntax errors show the line and column. Nothing is uploaded.
How to use
Paste your JSON into the box, pick an indent width, then click Format to pretty-print, Minify to strip all whitespace, or Validate to check syntax without changing the text. If the JSON is invalid, the error message includes the line and column where the parser stopped, so you can jump straight to the problem.
Why format JSON?
APIs and config files often return JSON as a single dense line. Pretty-printing adds indentation and newlines so a human can read the structure — nested objects, arrays, and key-value pairs line up visually. Minifying does the reverse: it removes every unnecessary character to shrink file size for transmission. This tool does both, plus validation, without sending your data anywhere.
FAQ
Is my JSON sent to a server?
No. Parsing and formatting happen entirely in your browser tab via
JSON.parse and JSON.stringify. Close the tab and the
input is gone.
What does the error line number mean?
It is the 1-based line and column in your pasted text where the parser first hit invalid syntax. The most common causes are a trailing comma, a missing quote, or single quotes instead of double quotes.
Does it handle large files?
Yes, up to your browser's memory limit — typically several megabytes. The result area scrolls so the page stays usable.
How to use the JSON formatter
- Paste your JSON into the input box — a single-line minified blob, a config file, or an API response copied from the network tab.
- Click Format to pretty-print it with two-space indentation, or Minify to strip all whitespace for production.
- Click Validate to check syntax without changing anything. If it fails, the error message includes a line and column number.
- Copy the result back into your editor with the copy button.
How it works
Parsing uses the browser's own JSON.parse, which means validation
is exactly as strict as the JavaScript engine you are running — no custom parser,
so no divergence in behaviour. Pretty-printing is JSON.stringify with
an indentation argument. Because the whole thing is native code, a five-megabyte
file formats in about the time it takes to blink, and nothing is uploaded to do
it. When a parse error occurs, the formatter reads the character position out of
the error message and translates it into a line and column so you can jump
straight to the problem in your editor.
Is my JSON safe to paste here?
Yes. The text never leaves your browser: no request is made, no API is called, and nothing is stored after you close the tab. This matters more than usual for JSON, which often contains API keys, tokens, customer records or internal hostnames. Pasting a production config into a random online formatter is a real leak risk; doing it here is not.
Troubleshooting
- "Unexpected token } in JSON at position…": usually a trailing comma before a closing brace or bracket. JSON does not allow them, unlike JavaScript object literals.
- "Unexpected token ' in JSON": that is a single-quoted string. JSON requires double quotes around both keys and string values.
- "Unexpected end of JSON input": the text is truncated — common when copying a long response out of a terminal or a log viewer.
- Bad control character: a raw newline or tab inside a string
value. It must be escaped as
\nor\t. - Works here but fails in my app: check for a UTF-8 byte order mark at the start of the file, which some Windows editors add.
FAQ
Does it handle very large files?
Up to a few megabytes comfortably, since the work is done natively in your browser. Beyond roughly 50 MB you may hit memory limits; split the file if so.
Can it fix my JSON automatically?
No — it reports where the syntax breaks rather than guessing your intent. Silently "repairing" malformed JSON usually produces a document that parses but means something different, which is worse than an error.
Will formatting change key order?
No. Key order is preserved exactly as parsed, so diffs against the original stay readable.
What about JSON5, YAML or comments?
Not supported — this is a strict JSON tool. Strip comments (or convert from YAML) before pasting.
People also use this for…
Every tool below is also 100%% local: no upload, no account, no server copy — the same privacy guarantee you get on this page.
- Estimate what that payload costs to send
Token counts drive API cost — check the price table. - Measure the raw text size
Character and word counts before you minify. - Generate the token or secret you are pasting
Made locally with crypto.getRandomValues.