You have a wall of JSON on one line — probably an API response — and you need it readable. Learning how to format JSON online takes about ten seconds: paste it into a free JSON formatter, click Format, and copy the indented result back. No install needed.
If you would rather stay in your own tools, you have good options there too: VS Code formats JSON with one shortcut, Python ships a built-in pretty-printer, and jq handles it from the terminal. This guide covers all four routes, explains what formatting actually changes, and walks through the five syntax errors that stop a formatter from running at all.

How to Format JSON Online in One Click (No Install)
An online formatter is the right call when you have a one-off blob of JSON and just want to read it. Paste the raw text into the input box, pick your indent size (two spaces is the usual default), and click Format. The tool parses your JSON and prints it back with one value per line and indentation that shows the nesting.
Here is what that looks like. Before formatting, an API might hand you this:
{"user":{"id":4812,"name":"Maya Chen","email":"maya@example.com","roles":["editor","reviewer"]},"active":true}
After formatting, the same data reads like this:
{
"user": {
"id": 4812,
"name": "Maya Chen",
"email": "maya@example.com",
"roles": [
"editor",
"reviewer"
]
},
"active": true
}
Nothing about the data changed — only the whitespace. But the second version is one you can actually scan, and a misplaced value or a missing field jumps out at once.
A good formatter also validates as it goes. If your JSON has a syntax error, it tells you where the problem is instead of silently producing broken output. That alone makes the online route worth it when you are debugging a payload you did not write. Toollan’s JSON Formatter runs entirely in your browser, so the text you paste never leaves your own machine — worth knowing if the payload contains API keys or personal data.
What “Formatting” JSON Actually Does (and Doesn’t Do)
Formatting — also called pretty-printing — only changes whitespace: line breaks and indentation. It does not change keys, values, order, or data types. A formatted file and a minified file with the same content are identical as far as any program reading them is concerned.
What formatting does do is make structure visible. Indentation shows you which values belong to which object, and one-value-per-line layout makes it easy to compare two files line by line. That is why formatted JSON is the standard for config files, saved API responses, and anything a human has to read or edit — and why knowing how to format JSON online is a basic skill for anyone who works with APIs.
What formatting does not do:
- It does not fix invalid JSON. If the input has a trailing comma or a missing quote, a formatter reports the error — it does not guess what you meant.
- It does not sort your keys unless you ask it to. Most formatters keep the original key order; some offer a sort option.
- It does not change the data. Numbers stay numbers, strings stay strings, and
nullstaysnull. Formatting is a display change, not a data change. - It does not make a file smaller. Formatted JSON is larger than minified JSON, because of all the added spaces and line breaks. That is the trade-off for readability.
If you need to check whether a JSON document matches a required structure — the right fields, the right types — formatting is not enough. That is a validation job, and a JSON Schema Validator checks your data against a schema and lists exactly which fields fail.
Format JSON in VS Code (Built-In Shortcut)
If the JSON lives in a file you are already editing, VS Code has a formatter built in. No extension needed.
Open the .json file and press Shift + Alt + F on Windows or Linux, or Shift + Option + F on macOS. VS Code reformats the whole document in place, using two-space indentation by default. You can also right-click in the editor and choose Format Document, or open the Command Palette with Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (Mac) and type “Format Document”.

A few details that save time:
- Format on save. Turn on
editor.formatOnSavein your settings and VS Code formats the file every time you save it. Your JSON stays tidy without you thinking about it. - Format a selection. Select part of a file and use Ctrl + K, Ctrl + F (Windows/Linux) or Cmd + K, Cmd + F (Mac) to format only the selected lines.
- Check the language mode. If the file does not end in
.json, VS Code may not know it is JSON. Look at the language indicator in the bottom-right of the status bar and set it to JSON if needed. Files like.babelrcandtsconfig.json(which allow comments) use the JSONC mode, and the same shortcut works there. - Prettier takes over if installed. If your project uses the Prettier extension, it becomes the default formatter and follows your
.prettierrcsettings. That is usually what you want on a team project, since everyone gets the same output.
If the shortcut does nothing, the usual cause is a syntax error in the file. VS Code shows a red squiggle at the problem spot — fix that first, then format again.
Format JSON in Python and With jq
For files on a server, API responses in a pipeline, or anything you want to script, the terminal is the better home for formatting. Python and jq cover almost every case.
Python: json.dumps and json.tool
Python’s built-in json module pretty-prints with one argument:
import json
data = {"user": {"id": 4812, "name": "Maya Chen"}, "active": True}
print(json.dumps(data, indent=2))
The indent=2 argument sets two-space indentation. Add sort_keys=True if you want keys in alphabetical order, which makes two files easy to compare with diff. Add ensure_ascii=False if your data contains non-English characters and you want them printed as-is instead of as \u escape codes.
For files and pipes, you do not need a script at all. Python ships json.tool as a command-line utility:
# Format a file and print it
python3 -m json.tool data.json
# Format piped input, for example an API response
curl -s https://api.example.com/users | python3 -m json.tool
# Save the formatted output to a new file
python3 -m json.tool data.json > formatted.json
# Sort keys and keep non-ASCII characters readable
python3 -m json.tool --sort-keys --no-ensure-ascii data.json
Two things to know about json.tool: it indents with four spaces by default (use --indent 2 to change that), and it exits with a non-zero status when the input is invalid JSON — which makes it handy as a quick validation check in scripts. On Windows, use python instead of python3 if that is how Python is on your PATH.

jq: the dedicated JSON command-line tool
jq is a small program built for working with JSON from the terminal. Unlike json.tool, it is not pre-installed — install it with your package manager (brew install jq on macOS, sudo apt install jq on Debian/Ubuntu, choco install jq on Windows). Once installed, the simplest use is:
# Pretty-print a file
jq . data.json
# Pretty-print an API response
curl -s https://api.example.com/users | jq .
jq earns its keep when you want more than formatting. It can pull out a single field (jq .user.name data.json), filter an array, or reshape the data — jobs json.tool cannot do. If you only need pretty-printing, Python’s built-in tool is enough. If you work with JSON in the terminal every day, jq is worth installing.
The 5 JSON Syntax Errors That Break Everything
Every formatter — online, in VS Code, or on the command line — refuses to run on invalid JSON. These five mistakes cause nearly all failures:
- Trailing commas. A comma after the last item in an object or array is valid in JavaScript but not in JSON.
{"a": 1,}fails. Remove the comma. - Single quotes. JSON strings must use double quotes.
{'name': 'Maya'}is not valid JSON;{"name": "Maya"}is. - Unquoted keys. Every key needs double quotes.
{name: "Maya"}fails;{"name": "Maya"}works. - Missing commas between items.
{"a": 1 "b": 2}is missing the comma after1. Easy to do when you delete a line by hand. - Comments. Plain JSON has no comments.
// noteor/* note */inside a.jsonfile is a syntax error. (Config files that allow comments use the JSONC format instead.)
When a formatter reports an error, it usually gives you a line and column number. Go to that spot and look just before it — the real mistake is often one character earlier than the reported position, for example a missing comma on the previous line. Paste the file into the JSON Formatter if you want the error pointed out in plain language.

Minify vs Format: When to Use Each
Minifying is the reverse of formatting: it strips out all unnecessary whitespace and puts the JSON on one line. The two forms serve different purposes, and using the right one at the right time matters.
| Formatted (pretty-printed) | Minified | |
|---|---|---|
| Best for | Reading, editing, debugging, config files, saved responses | Sending over a network, storing large files, production APIs |
| File size | Larger (all that whitespace) | Smallest possible |
| Human-readable | Yes | No — one long line |
| Machine-readable | Yes | Yes — identical data |
The practical rule: keep files formatted while you work on them, and minify when size matters — usually when an API sends a response or a build step bundles a large JSON file. Most tools that produce JSON for production minify automatically, so you rarely need to do it by hand. And if a minified file lands in your lap, you now know how to format JSON online and three other ways to make it readable again.
Frequently Asked Questions
How to format JSON online for free?
Paste your JSON into a free online formatter such as Toollan’s JSON Formatter, click Format, and copy the indented result. No account or install is needed, and the formatting runs in your browser.
What is the VS Code shortcut to format JSON?
Press Shift + Alt + F on Windows or Linux, or Shift + Option + F on macOS, with the JSON file open. You can also right-click and choose Format Document, or run Format Document from the Command Palette.
How do I pretty-print JSON in Python?
In code, use json.dumps(data, indent=2). From the terminal, run python3 -m json.tool file.json — it needs no extra packages and works on files or piped input.
Why won’t my JSON format?
Almost always a syntax error: a trailing comma, single quotes, an unquoted key, a missing comma, or a comment. Fix the error at the line and column the formatter reports, then try again.