How To Format JSON: Pretty Print and Read JSON Easily
Formatting JSON makes it easier to read, debug and share. A JSON formatter takes compact or messy JSON and turns it into a clean, indented structure.
- Formatting JSON adds indentation and line breaks.
- Pretty printed JSON is easier to read and debug.
- Minified JSON removes spaces to reduce file size.
- Invalid JSON must be fixed before it can be formatted properly.
What does formatting JSON mean?
Formatting JSON means arranging JSON data with indentation, spacing and line breaks so it is easier for humans to read.
Computers do not need nicely formatted JSON, but humans definitely do. Especially when one missing comma turns a five-minute task into a small detective drama.
Unformatted JSON example
This JSON is valid, but it is difficult to scan because everything is on one line.
{"name":"Jane Smith","role":"Chief Cheese Tester","active":true,"tools":["JSON Formatter","JSON Viewer"]}
Formatted JSON example
After formatting, the same JSON becomes easier to read.
{
"name": "Jane Smith",
"role": "Chief Cheese Tester",
"active": true,
"tools": [
"JSON Formatter",
"JSON Viewer"
]
}
What is JSON pretty print?
JSON pretty print means formatting JSON with indentation and spacing so the structure is visually clear.
Pretty printing usually adds:
- Line breaks
- Indentation
- Spaces after colons
- Clear nesting for objects and arrays
Formatting JSON vs minifying JSON
| Action | What it does | Best for |
|---|---|---|
| Format / Pretty print | Adds spacing, indentation and line breaks. | Reading, debugging and editing JSON. |
| Minify | Removes unnecessary spaces and line breaks. | Reducing file size for transfer or storage. |
How to format JSON
- Copy your JSON data.
- Paste it into a JSON formatter.
- Check whether the JSON is valid.
- Format or pretty print the JSON.
- Copy the cleaned output.
Format JSON online
Use CheeseBridge JSON Formatter to clean up, pretty print and inspect JSON directly in your browser.
Open JSON Formatter Open JSON ViewerCommon JSON formatting errors
A formatter can only format JSON correctly if the JSON is valid.
| Error | Example problem | How to fix it |
|---|---|---|
| Trailing comma | { "name": "Jane", } |
Remove the comma after the last property. |
| Single quotes | { 'name': 'Jane' } |
Use double quotes for strings and property names. |
| Missing comma | { "name": "Jane" "role": "Tester" } |
Add a comma between properties. |
| Comments | // this is a comment |
Remove comments from standard JSON. |
Invalid JSON example
This JSON is invalid because it has a trailing comma.
{
"name": "Jane Smith",
"role": "Chief Cheese Tester",
}
Fixed JSON example
The fixed version removes the final comma.
{
"name": "Jane Smith",
"role": "Chief Cheese Tester"
}
Why format JSON?
- To make JSON easier to read.
- To debug API responses faster.
- To inspect nested objects and arrays.
- To find mistakes more easily.
- To share clean JSON with other people.
JSON formatting best practices
- Use consistent indentation.
- Use double quotes for all strings and keys.
- Avoid unnecessary nesting.
- Validate JSON before sharing it.
- Minify JSON only when readability is not needed.
Trusted JSON references
For official and technical references, see:
Frequently asked questions
What does JSON formatting do?
JSON formatting adds indentation, spacing and line breaks to make JSON easier to read and debug.
What is pretty printed JSON?
Pretty printed JSON is JSON that has been formatted with clear indentation and line breaks.
Can invalid JSON be formatted?
Not properly. Invalid JSON usually needs to be fixed before a formatter can clean it up.