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.
- 4If 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. |
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.
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