Quick answer
- In the browser: paste into FormatArc's JSON Formatter — runs fully client-side, no upload
- In the terminal:
echo '{...}' | jq .orpython3 -m json.tool - In code:
JSON.stringify(data, null, 2)in JavaScript/Node.js
The rest of this guide covers these three paths with examples, common parse errors, and when to pick each one.
What is JSON formatting?
JSON (JavaScript Object Notation) is one of the most widely used data formats. You see it in API responses, configuration files, and data exchanges between services.
However, minified JSON is hard for humans to read, so pretty-printing it to reveal the structure is a routine task for developers.
Common JSON syntax errors
1. Trailing commas
{
"name": "example",
"value": 42,
}
A comma after the last property is invalid JSON. JavaScript allows it, but the JSON specification does not.
2. Single quotes
{'name': 'example'}
JSON requires double quotes ". Single quotes ' are not valid.
3. Unquoted keys
{name: "example"}
Every key in JSON must be wrapped in double quotes.
Pretty-print JSON with JSON.stringify()
In JavaScript and Node.js, JSON.stringify() accepts a third argument for indentation. This is the quickest way to pretty-print JSON in code:
const data = { name: "Alice", age: 30, roles: ["admin", "editor"] };
// Pretty-print with 2-space indent
console.log(JSON.stringify(data, null, 2));
Output:
{
"name": "Alice",
"age": 30,
"roles": [
"admin",
"editor"
]
}
The second argument (null here) is a replacer function or array that filters which properties to include. Pass null to keep everything.
You can also use a tab character for indentation:
JSON.stringify(data, null, "\t");
Pretty-print JSON in the terminal
Using jq
jq is a lightweight command-line JSON processor. Pipe any JSON output through it to get formatted results:
echo '{"name":"Alice","age":30}' | jq .
Using Python
Python ships with a built-in JSON module that works as a quick formatter:
echo '{"name":"Alice","age":30}' | python3 -m json.tool
Using curl with jq
When debugging APIs, combine curl with jq to pretty-print the response:
curl -s https://api.example.com/data | jq .
Format JSON in your browser
FormatArc's JSON Formatter lets you pretty-print JSON entirely in the browser. Your data is never sent to a server, making it safe for API payloads and internal configs.
How to use it
- Paste your JSON into the input area
- Click "Run"
- Copy the formatted output
Three simple steps to clean, readable JSON.


Validate JSON before formatting
If your JSON is malformed, pretty-printing will fail. The most common causes are trailing commas, single quotes, and unquoted keys (covered above). If you need comments in your config files, see JSONC, JSON5, and other workarounds. When you run into a parse error, the error message usually includes a character position — but that can be hard to map to the actual problem in a large file.
FormatArc's JSON Formatter shows the approximate line number where the error occurred, making it easier to jump to the right spot. For a deeper walkthrough of common parse errors and how to fix them, see How to Fix JSON Parse Errors.
Auto-format JSON with a Chrome extension
If you often open API endpoints directly in the browser, a Chrome extension can auto-format the response for you. See Top JSON Formatter Chrome Extensions Compared for a breakdown of JSONView, JSON Formatter, and other popular options.
Working with other data formats
JSON formatting is often part of a larger workflow that involves converting between formats:
- YAML vs JSON — understand when to use each format
- Convert YAML to JSON — turn Kubernetes configs and CI files into JSON
- Convert CSV to JSON — transform spreadsheet exports into JSON arrays
- JSON Syntax Guide — the fundamentals of writing valid JSON
- Using formatarc as an npm Package — format JSON from the terminal with the formatarc CLI
- Pretty-Print curl JSON Responses — format API responses directly from curl with jq or python one-liners
Try it now
Have messy JSON that needs formatting? Open the JSON Formatter, paste your data, and get clean output instantly. No signup, no server — everything stays in your browser.
Summary
- JSON pretty-printing is an everyday task in development and operations
- Use
JSON.stringify(data, null, 2)to pretty-print JSON in JavaScript - In the terminal, pipe JSON through
jqorpython3 -m json.tool - The most common syntax errors are trailing commas, single quotes, and unquoted keys
- FormatArc formats JSON safely in the browser with no server involved