JSON Formatter
Pretty-print and validate JSON in your browser. No upload, no signup. Sort keys, choose your indent, copy with one click.
What is a JSON formatter?
A JSON formatter takes raw JSON and rewrites it in a consistent, human-readable shape — adding indentation so nested structures are visible, normalizing whitespace, and (often) sorting keys for diff-friendliness. Behind the scenes it’s a parse step followed by a stringify step: the input is turned into an in-memory value, then serialized back out with your chosen indent.
JSONZen’s formatter goes one step further: when the input is broken, it doesn’t just print “Invalid JSON” — it tells you the exact line and column where the parser gave up, and highlights it in the editor.
When do you need one?
- You copied a one-line JSON blob from a network tab and need to read it.
- Your build output, log, or API response is minified and unreadable.
- You’re committing a configuration file and want consistent indent + sorted keys so diffs stay clean.
- You’re debugging a “SyntaxError: Unexpected token” and need to know which character caused it.
How to use it (3 steps)
- Paste your JSON into the left panel.
- Pick an indent (2 spaces, 4 spaces, or tabs) and switch to Sorted JSON if you want alphabetical keys.
- Click Copy in the bottom-left to put the formatted output on your clipboard.
Everything happens in your browser. Nothing is sent to a server, ever. Close the tab and your data is gone — that’s the privacy promise.
Common errors, decoded
- Unexpected token } in JSON
- You probably have a trailing comma right before that closing brace. Vanilla JSON doesn’t allow trailing commas (JSON5 does, but the spec doesn’t).
- Unexpected end of input
- A bracket, brace, or quote was left open. Scroll to the bottom — you’re missing a closer somewhere on the way there.
- Unexpected token a in JSON at position 1
- The first non-whitespace character is a letter, which means an unquoted key (e.g.
{a:1}) or a JavaScript object literal that isn't valid JSON. Wrap keys in double quotes.
Frequently asked questions.
- Is JSONZen free?
- Yes. The core JSON tools are free and no signup is required. The formatter runs entirely in your browser — your JSON is never sent to any server.
- Does it work offline?
- Yes. After the first page load, the formatter works without an internet connection. Everything happens client-side in JavaScript.
- How big a JSON file can I format?
- Roughly anything up to ~10 MB without noticeable lag. Beyond that, the editor stays responsive thanks to React’s deferred-value rendering, but the very first format pass can take a couple of seconds.
- Can it sort object keys alphabetically?
- Yes — switch to the "Sorted JSON" tab and JSONZen recursively sorts keys in every nested object. Array element order is preserved.
- What does "line N, column M" mean when I get an error?
- It points to the exact character where the JSON parser gave up. Line numbers count from 1 and reflect newlines (\n) in your input.
- Can I validate JSON Schema with this?
- Yes — use the Validator tool at /validate. It supports JSON Schema versions 07, 2019-09, and 2020-12 with detailed per-path error messages, powered by Ajv.