JSON Beautifier
Beautify minified JSON with 2 or 4 space indentation and see the parser error if it is invalid.
Runs in your browser Your input never leaves your device.
Report a problem with this tool
About this tool
Paste minified or messy JSON and get it back indented and readable, with a choice of 2 or 4 spaces. Formatting happens in your browser using the standard JSON parser, so the data is never uploaded. Because the text is fully parsed first, the tool doubles as a quick syntax check: if the JSON is invalid you get the parser's error message instead of output. Keys and values are kept, but the output is written fresh from the parsed data, so a few details can change: numbers are written in their shortest form, escapes like \u00e9 become the character itself, a duplicated key keeps only its last value, and keys that look like whole numbers move to the front of their object. See the section below for details.
How to use it
- Paste your JSON into the input box.
- Choose 2 or 4 spaces for the indent.
- Read the formatted result below, or fix the error message if the JSON is invalid.
- Copy the output.
Example
Minified input, 2-space indent:
{"name":"John","age":28,"tags":["a","b"]}{
"name": "John",
"age": 28,
"tags": [
"a",
"b"
]
}What beautifying changes, and what it does not
The tool parses your JSON and writes it out again with indentation. For most data the only difference is whitespace. These are the cases where the output can differ from the input in more than layout:
- Number form
- Numbers are rewritten in their shortest form, so 1.0 becomes 1 and 1e2 becomes 100. Integers larger than 9007199254740991 can lose precision: 12345678901234567890 comes out as 12345678901234567000.
- Escaped characters
- An escape such as \u00e9 is written as the character é. Quotes, backslashes and control characters stay escaped.
- Duplicate keys
- If an object has the same key twice, only the last value is kept.
- Key order
- Keys keep their order, except keys that look like whole numbers (such as "1" or "42"), which move to the front of their object in ascending order.
Beautify JSON from the command line
If you work with JSON files often, two common command-line options produce the same kind of output. Python's json.tool indents with 4 spaces by default; jq indents with 2.
python3 -m json.tool data.json python3 -m json.tool --indent 2 data.json jq . data.json
When you need more than indentation
- Browse large or nested data
- The JSON Tree Viewer shows the data as a collapsible tree with search and copyable paths.
- Check the structure
- The JSON Schema Validator checks the data against a schema, not just the syntax.
- Compare two versions
- JSON Diff shows what changed between two JSON documents.
- Pick out values
- The jq Playground runs jq filters on your JSON.
Common problems
- Trailing comma
- JSON does not allow a comma after the last item in an object or array. Remove it.
- Single quotes or unquoted keys
- Keys and strings must use double quotes. {name: 'x'} is JavaScript, not JSON.
- Comments in the JSON
- Standard JSON has no comments. Remove // and /* */ before formatting.
- Unexpected token at a position
- The error shows where parsing failed; look just before that position for a missing comma, quote or bracket.
Frequently asked questions
Does formatting change my data?
Almost never. Usually only whitespace changes. A few details can differ because the output is written from the parsed data: numbers in their shortest form, \u escapes as characters, the last value of a duplicated key, and number-like keys moved first. See the section above.
Is my JSON uploaded anywhere?
No. The formatting runs entirely in your browser.
Can this tool minify JSON as well?
No. It only adds indentation, with 2 or 4 spaces. To put JSON on one line, run JSON.stringify(JSON.parse(text)) in your browser's developer console.
Is there a size limit?
Text over 1,000,000 characters is not processed, so the page does not freeze. Split very large files, or use a command-line tool such as jq.
What is the difference between a JSON beautifier and a JSON validator?
A validator only tells you whether the text is valid JSON. A beautifier also rewrites valid JSON with indentation. This tool does both, because it has to parse the JSON before it can format it.