What the beautifier does
An API often returns JSON on a single line. This tool adds line breaks and indentation so that you can see the structure. Keys, strings, numbers and the words true, false and null get different colors, and each line has a number, so it is easy to talk about line 47 of a response. Copy and Download give you the plain text without colors.
Before and after
{"id":7,"tags":["a","b"],"owner":{"name":"Sam","active":true}}
{
"id": 7,
"tags": [
"a",
"b"
],
"owner": {
"name": "Sam",
"active": true
}
}
Options
- Indent of 2, 4 or 8 spaces, or a tab.
- Sort keys A to Z in every object.
- Accept comments and trailing commas for JSONC style config files.
Large files
Colors and line numbers are shown for up to 5,000 lines. A longer result is shown as plain text in a scrollable box, and Copy still gives you everything.
How to beautify JSON in three steps
- Paste the JSON, or press Open file and choose a .json file.
- Pick the indent: 2 spaces, 4 spaces, 8 spaces or a tab. Tick Sort keys if you want alphabetical order.
- Read the result with colors, then press Copy or Download.
Why beautified JSON is easier to work with
- Debugging. You can see which object a value belongs to and how deep it sits.
- Code review. A formatted file gives line-by-line diffs, so reviewers see exactly what changed.
- Documentation. Examples in docs and tickets are much easier to follow when they are indented.
- Finding mistakes. A missing bracket or a misplaced comma shows up as an error with a line number.
Beautifying JSON that is not valid
A beautifier needs valid JSON to know where each value starts and ends. If the input has a mistake, the tool shows the line and column instead of guessing. Comments and trailing commas are accepted when the option is on. For other errors, use the JSON validator to find and fix the problem, then beautify again.
Where minified JSON comes from
- API and webhook responses, which are sent compact to save bandwidth.
- Log lines and database columns that store a whole document on one line.
- Build tools and exports that write one-line JSON files.
- Network traces copied from browser developer tools.
Pretty print JSON in code
// JavaScript JSON.stringify(JSON.parse(text), null, 2) # Python print(json.dumps(json.loads(text), indent=2)) // PHP echo json_encode(json_decode($text), JSON_PRETTY_PRINT); # Command line, with color curl -s https://api.example.com/data | jq .
These calls pass numbers through floating point. For very large integers, paste the JSON here instead, because this tool keeps number text exactly.
Reading the colors
- Purple: property names (keys).
- Blue: string values.
- Orange: numbers.
- Gold: true, false and null.
Beautify, format, pretty print
These names mean the same thing for JSON: add whitespace to make it readable. The JSON formatter has extra layout options, and the JSON minifier reverses the process. Beautifying never changes the data, only the whitespace. Number text, such as 1.50, is kept as it is.
Your JSON stays in your browser. See also the JSON validator, the JSON compressor and the JSON minification guide.