JSON Formatter
Format, minify, and validate JSON with line-and-column error reporting
What is JSON Formatter?
A JSON formatter re-indents minified or messy JSON into a readable, properly nested structure while validating the syntax and pointing to the exact line and column of any error. Parsing runs on your own machine through the browser's built-in JSON engine, so the text you paste is never uploaded to a server.
How to use JSON Formatter
- 1Paste your JSON into the input box on the left; the tool parses it as you type.
- 2Use the indentation selector to output 2 spaces, 4 spaces, or tabs.
- 3Click "Minify" for a single-line JSON string with every bit of whitespace removed — ideal for config values and URL parameters.
- 4When a string field holds another JSON document — routine in logs and message queues — that field gets a dashed underline and a {} icon in the right-hand pane. Click it to read the inner document formatted in a dialog, and keep clicking to go deeper.
- 5If the syntax is invalid, the right-hand pane shows the error position along with the raw parser message so you can fix it and re-parse.
How do I do this in code?
Use the tool above for one-off work; for anything you repeat, move it into a script or your project.
// Pretty-print: the third argument is the number of spaces to indent const pretty = JSON.stringify(JSON.parse(raw), null, 2); // Minify: simply omit the third argument const minified = JSON.stringify(JSON.parse(raw));
Common errors and how to fix them
| Symptom | Cause | Fix |
|---|---|---|
| Unexpected token } in JSON | There is an extra comma after the last key/value pair, and the JSON spec does not allow trailing commas. | Delete the comma that follows the final item of the object or array. |
| Expected property name or '}' | Keys or string values are wrapped in single quotes, but JSON only accepts double quotes. | Replace every single quote with a double quote — property names must be double-quoted too. |
| Non-ASCII characters come out as escapes like \u00e9 or \u4f60\u597d | The JSON was produced with ASCII escaping turned on — Python's json.dumps defaults to ensure_ascii=True, for example. | Pass ensure_ascii=False when generating the JSON; this tool always renders UTF-8 characters as they are. |
| After formatting, one field is still a long escaped blob like \"a\":1 | That value is a whole JSON document escaped into a string, so as far as the outer document is concerned it is just text — indentation cannot reach inside it. | Click the {} icon beside the field to read the inner JSON formatted in a dialog, and click again if there is yet another layer inside. |
Frequently asked questions
Does this JSON formatter upload my data to a server?+
No. Parsing and formatting happen entirely in your browser through its native JSON engine, and the page has no upload endpoint at all. Open the Network panel in your browser DevTools and you can confirm that no request carries your input while you work.
Why is my JSON failing validation?+
The three usual suspects are a trailing comma, single quotes instead of double quotes, and unbalanced brackets. The tool reports where parsing stopped, and scanning backwards from that point for those three problems almost always finds it. Comments are invalid too: JSON supports neither // nor /* */.
Can it handle very large JSON files?+
Documents of a few megabytes are fine in a modern browser; for anything substantially bigger, reach for jq on the command line. You may see a short freeze while a large document is parsed, which is just the main thread doing one big parse and says nothing about the safety of your data.
How do I read JSON nested inside a string field?+
Every string field whose value is itself a JSON document gets a dashed underline and a {} icon in the output pane. Click it and the inner document opens formatted in a dialog, with the same syntax highlighting and find widget. Double or even triple encoding is common in logs and message queues, so you can keep drilling: the breadcrumb at the top records the path, and clicking a segment takes you back up. The command-line equivalent is jq '.payload | fromjson'.
Related tools
All toolsJSON Validator
Validate JSON syntax and pinpoint the failing line and column
JSON Viewer
Explore JSON as a collapsible tree and read off access paths
JSON Escape / Unescape
Escape and unescape JSON strings
SQL Formatter
Beautify SQL per dialect, including MySQL and PostgreSQL
XML Formatter
Pretty-print or minify XML while checking that every tag is closed
YAML Formatter & Validator
Validate YAML syntax and normalize the indentation