What is JSON pretty printing?
JSON pretty printing is the practice of writing a valid JSON document so a human can scan it: every key on its own line, arrays broken out item by item, and each nesting level pushed further right than the one above it. Where a server hands you one long line of braces, a pretty printed document shows the structure instead of hiding it.
Only whitespace changes. Keys, values, numbers, booleans, nulls, nesting and the order of every entry stay exactly as they came in, so the document you paste back into your code still means precisely the same thing. Nothing is renamed, sorted, rounded or converted.
The vocabulary overlaps on purpose: JSON pretty print, JSON beautify and format JSON all describe the same operation - parse the document and write it back out with consistent indentation. This page does that with a choice of two, four or one space per level.
How to pretty print JSON online
Paste the JSON you want to make readable into the JSON input panel. Minified, compact, hand-written or already formatted all work, and the example loaded by default is a good test of nested output.
Pick the indentation, then press Pretty Print JSON. The result appears in the panel on the right with the width you selected and one entry per line. The output also updates automatically as you type, which is useful when you are fixing an error character by character.
Press Copy to take the formatted document, or Clear to start over. Ctrl+Enter - Cmd+Enter on a Mac - runs the pretty print from anywhere on the page, and the example menu in the toolbar loads sample payloads.
- 1Paste your JSON into the input panel.
- 2Choose the indentation: 2, 4 or 1 space.
- 3Press Pretty Print JSON - or let it format as you type.
- 4Copy the readable result from the output panel.
JSON pretty print example
The same document before and after pretty printing - this is exactly the input the tool above starts with:
{"name":"John","age":30,"address":{"city":"New York","zip":"10001"}}{
"name": "John",
"age": 30,
"address": {
"city": "New York",
"zip": "10001"
}
}The data is identical in both versions:"name": "John" is still the same string,30 is still the same number, and the nested address object keeps its two properties in the same order. Whitespace and line breaks are the only difference, and that is what makes the nesting easy to read.
Why pretty print JSON?
Most pretty printing happens in the first minute of working with JSON somebody else produced. The usual cases:
API responses
A server usually returns JSON as a single line so the payload stays small. Copy that line out of a terminal or a network tab and it is one unbroken stream of braces. Pretty print it and the field you are hunting for becomes findable by eye, with each nesting level visible at a glance.
Webhook payloads
Webhook bodies tend to nest several levels deep - payment events, order items, customer addresses, nested metadata. In compact form you are counting braces to work out where you are; pretty printed, the depth is visible and the field paths are obvious.
Configuration files
JSON that people read and edit - editor settings, CI configuration, feature flags, package manifests - belongs in a repository in readable form. Pretty print before committing so a reviewer can see what actually changed instead of one giant modified line.
Debugging
While debugging, indentation tells you which level a value lives at. Pretty print the payload you are logging and a mismatched key, a missing field or an array in the wrong place stands out immediately instead of hiding in the middle of a line.
Documentation
Examples in documentation, READMEs and bug reports have to be readable by whoever opens them next. Pretty printed JSON can be understood without copying it into an editor first, which is exactly what you want in a ticket or a pull request comment.
Pretty print vs minify JSON
Pretty printing and minifying are opposite operations on the same document, and neither one changes your data. You can move a JSON file back and forth between them without losing anything: one adds whitespace for people, the other removes it for machines.
| Aspect | Pretty Print | Minify |
|---|---|---|
| Goal | Make JSON readable | Make JSON as small as possible |
| What it does | Adds indentation and line breaks | Removes all insignificant whitespace |
| Typical result | Indented, multi-line block | One long line |
| Best for | Reading, reviewing, debugging, documenting | Request bodies, URLs, caching, storage |
| Data changes | None | None |
Need the compact version for a request body, a URL or storage? Use the JSON Minifier to strip the whitespace back out of the same document.
JSON pretty print vs JSON beautifier
JSON pretty print, JSON beautify and JSON format are three names for one transformation. A JSON beautifier and a JSON pretty printer produce the same document: one entry per line, consistent indentation, data untouched. There is no output from one that the other cannot produce.
Calzyra keeps a JSON Beautifier and a JSON Formatter page as well, because people arrive searching for all of those names. Use whichever page matches the words you searched for - the operation, and the result, are identical.
Searched for a beautifier or a formatter instead? The JSON Beautifier and the JSON Formatter run the same whitespace-only transformation, so any of the three names gives you the same readable document. If you want keys alphabetised as well, that is the JSON Sorter, not a pretty printer.
Common JSON formatting errors
Pretty printing is layout, not repair. The document has to parse as standard JSON before it can be laid out, and the strictness catches people out constantly. These are the problems that come up most often:
Trailing commas
A comma after the last entry - {"a":1,"b":2,} - is valid in JavaScript but not in JSON. Remove the comma before the closing brace or bracket.
Single quotes
JSON strings and object keys must use double quotes. {'name': 'John'} parses in JavaScript and fails in JSON.
Unquoted property names
Every key has to be a quoted string: {name: "John"} is not valid JSON, even though it looks like an object literal.
Missing commas
Two entries with no comma between them - {"a":1 "b":2} - is the most common one-character error in hand-written JSON.
Missing braces or brackets
An unclosed object, array or string is reported at the position where the parser ran out of structure, which is often far from where you forgot the character.
Comments
Standard JSON has no comment syntax. A // note or a /* block */ makes the document invalid, so move the explanation outside the JSON.
This tool will not guess at a repair. It reports the first position the parser could not accept, keeps your input exactly as you typed it, and formats nothing until the syntax is fixed. A trailing comma is enough to stop pretty printing, and the error below is produced by the same parser the tool runs:
{"name":"John","age":30,}For a dedicated syntax check on its own, run the same input through the JSON Validator.
JSON pretty printing for developers
Indentation width is a project convention, not a rule. Two spaces is the default in most JSON tooling - JSON.stringify in JavaScript and json.dumps in Python both write it - so output from this tool drops straight into code that expects the same shape. Four spaces shows up in Java projects and older style guides, and one space is the compact end of readable.
Pretty printing also makes version control honest. A config file committed with consistent indentation produces a diff where each changed line is a changed value; the same file minified produces one changed line containing the entire document.
There is a cost, though: indentation and line breaks are bytes. Pretty print for reading, reviewing and debugging, then minify before the JSON travels - over a request body, in a URL, or into storage.
One thing pretty printing deliberately does not do is reorder anything. Keys keep the order they were written in, which is the order most parsers preserve. If you want them alphabetised for a diff or a lookup, that is a separate operation.
const pretty = JSON.stringify(data, null, 2);import json
pretty = json.dumps(data, indent=2)jq . data.jsonFrequently Asked Questions
What is JSON pretty printing?
JSON pretty printing means writing a valid JSON document so a person can read it: one entry per line, arrays broken out item by item, and each nesting level indented further than the last. It is also called JSON beautifying or JSON formatting, and it only changes whitespace - the keys, values, types and structure stay exactly as they were.
How do I pretty print JSON online?
Paste your JSON into the input panel, choose the indentation, then press Pretty Print JSON. The readable result appears on the right and updates as you type, so you can watch an error disappear while you fix it. Press Copy to take the result, and Ctrl+Enter runs the pretty print from anywhere on the page.
Does pretty printing change JSON data?
No. Pretty printing only adds whitespace, indentation and line breaks, so the document means exactly the same thing to any program that reads it. Keys are not renamed, values are not converted, array order and key order are kept, and nothing is sorted. The only textual differences you may notice are normalisation: a number written as 1.0 can come back as 1, and an escape sequence may be written in its shortest form.
What is the difference between JSON pretty print and JSON beautify?
Nothing in the result - they are two names for the same operation. Parse the document and write it back out with consistent indentation, and you have pretty printed it and beautified it at the same time. Calzyra keeps separate JSON Beautifier and JSON Formatter pages because people search for all of the names, but every one of them produces the same readable layout.
Can I pretty print minified JSON?
Yes - minified JSON is the input this tool is built for. A single-line payload such as {"name":"John","age":30,"address":{"city":"New York"}} is expanded into an indented block with one entry per line. Already formatted JSON works too: running it again produces the same layout, so the tool is safe to use twice.
What indentation should I use for JSON?
Two spaces is the most common choice and the default here: JSON.stringify in JavaScript and json.dumps in Python both use it, so the output matches what most tooling expects. Four spaces is common in Java projects and some style guides, and one space is the most compact readable option. The JSON specification does not mandate an indentation width, so pick whichever matches your project - it is a cosmetic choice and never affects the data.
Can I pretty print invalid JSON?
No. A pretty printer can only lay out a document it can parse, so standard JSON has to be valid first - no trailing commas, no single quotes, no unquoted property names, no comments. If your document has a syntax error, this tool reports the parser message with the line, column and character position and leaves your input untouched. Fix the error and the formatted result appears; for a dedicated syntax check, use the JSON Validator.
Is this JSON pretty printer free, and does my JSON leave my browser?
It is free to use with no sign-up, no usage limit and no watermark. Pretty printing runs entirely in your browser: the document is parsed and written back out locally, so the JSON you paste is not sent anywhere for processing.