Formatting
How to format (beautify) JSON
Minified JSON is fast to transfer but painful to read. Formatting adds indentation and line breaks so you can actually follow the structure — without changing a single value. Here's how it works and how to do it in seconds.
Updated July 20264 min read
What "formatting" JSON actually does
JSON is often stored and transmitted minified — all optional whitespace removed to keep the payload small:
{"name":"Ada","roles":["admin","editor"],"active":true}That's efficient for a machine but hard for a human. Formatting (also called beautifying or pretty-printing) re-writes the same data with indentation and line breaks:
{
"name": "Ada",
"roles": [
"admin",
"editor"
],
"active": true
}Both snippets encode exactly the same object. Formatting only touches whitespace, so it is always safe — you never risk changing a value by beautifying it.
How to format JSON in the browser
The fastest way is a tool that runs locally so your data never leaves your machine. In the JSON Viewer & Formatter:
- Paste your JSON into the input, or open a file.
- Switch the output to Formatted to see it pretty-printed with 2-space indentation.
- Use Copy to grab the beautified result, or Minify to collapse it back to a single compact line.
Validation runs as you type, so if the JSON can't be formatted you'll see exactly where the problem is (more on that below).
Formatting vs. minifying
These are two directions of the same operation. Reach for each when:
- Format when you're reading, reviewing, or debugging — logs, API responses, config files.
- Minify when you're shipping — embedding JSON in a request body, a data attribute, or a file where size matters.
If you write JSON by hand in a code editor, you can also format programmatically with JSON.stringify(value, null, 2) for pretty output or JSON.stringify(value) to minify.
Why won't my JSON format?
A formatter can only pretty-print valid JSON. If nothing happens, the input almost always has one of these problems:
- Trailing commas —
{"a": 1,}is invalid; remove the comma after the last item. - Single quotes — JSON strings and keys must use double quotes, not
'single'quotes. - Unquoted keys —
{name: "Ada"}must be{"name": "Ada"}. - Comments — standard JSON does not allow
//or/* */comments. - Wrapping text — a leading label like
data = { … }or a trailing semicolon will break parsing.
A good formatter points to the exact line and column of the first error so you can fix it quickly. For the full rules, see JSON syntax explained.
Formatting large JSON files
Very large documents (tens of thousands of nodes) can be slow to read even when formatted. In that case, a tree view is often more useful than a wall of text: you can collapse branches and expand only what you need. Open big files in the workspace for a virtualized tree plus a filterable grid, or use the Tree view in the viewer for quick inspection.
Frequently asked questions
What does it mean to format or beautify JSON?
Formatting (or beautifying) JSON re-writes it with consistent indentation and line breaks so the structure is easy to read. It doesn't change the data — only the whitespace.
What is the difference between formatting and minifying?
Formatting adds whitespace to make JSON readable; minifying removes all optional whitespace to make the payload as small as possible. Both represent identical data.
How many spaces should JSON be indented?
Two spaces is the most common convention and the default in most tools, including JSON-Table. Four spaces and tabs are also valid — indentation is purely cosmetic.
Is it safe to format sensitive JSON online?
With JSON-Table, yes: formatting runs entirely in your browser and nothing is uploaded to a server, so private data never leaves your machine.