JSON Formatter and Beautifier
Turn minified or badly indented JSON into something readable, check that it is valid, and compact it again when you are done. It runs in your browser, so nothing is uploaded.
Format and minify
Beautify rewrites the document with two-space indentation and one value per line. Minify strips every space that is not inside a string, which is what you want before putting a document in a config file, an environment variable, or a URL.
Beautify also accepts Python dictionary syntax, so it doubles as a converter: paste a dict, press Beautify, and the box now holds valid JSON.
{"name":"Ada","langs":["py","js"],"active":true}
{
"name": "Ada",
"langs": [
"py",
"js"
],
"active": true
}Validation that points at the problem
When a document will not parse, the message names the line and column where the parser gave up, and that line is marked in the input. This is more useful than "invalid JSON", which is what most formatters tell you.
The commonest causes, in rough order of frequency: a trailing comma after the last item, single quotes instead of double quotes, an unescaped quote inside a string, a missing closing brace, and a stray comment. JSON allows none of those - though this tool will read all of them, because it understands Python literal syntax as well.
What it will not do
It will not repair a broken document by guessing. If a document is truncated halfway through, you get an error naming the position rather than a file with invented contents - a repaired document that looks fine but is wrong is worse than an error.
Questions
- How do I format JSON online?
- Paste the document into the input box and press Beautify. The text is reformatted with two-space indentation. Press Minify to compact it again.
- Why does my JSON say it is invalid?
- The most common causes are a trailing comma after the last element, single quotes instead of double quotes, and unescaped quotes inside a string. The error message here names the line and column where parsing failed, so you can go straight to it.
- Can it format a Python dictionary?
- Yes. Paste the dict and press Beautify: the tool reads Python literal syntax and rewrites the box as formatted JSON.