Paste messy JSON and read it in seconds
Got a wall of JSON that looks like gibberish? Paste it above and this JSON formatter instantly adds indentation, line breaks, and color so you can actually read it. It also catches syntax errors before they crash your code.
How to use this JSON formatter
- Paste your JSON into the input box above (or upload a
.jsonfile). - Choose your indent size — 2 spaces, 4 spaces, or a tab stop.
- Click Format to pretty-print, or Minify to compress it to one line.
- If there's a syntax error, the tool highlights the exact line and tells you what went wrong.
- Copy the result with one click or download it as a
.jsonfile.
Worked example: from raw to readable
Here's typical JSON straight from an API response — valid but completely unreadable:
{"user":{"id":42,"name":"Alice","roles":["admin","editor"],"active":true}}
After clicking Format with 2-space indent, you get:
{
"user": {
"id": 42,
"name": "Alice",
"roles": [
"admin",
"editor"
],
"active": true
}
}
Same data, zero ambiguity. You can immediately see the nested structure, spot the roles array, and check that active is a boolean — not the string "true".
Format JSON in your own code
Sometimes you need to pretty-print JSON directly in a script. Here's how to do it in the two most common languages:
JavaScript (Node.js or browser)
const raw = '{"user":{"id":42,"name":"Alice"}}';
const formatted = JSON.stringify(JSON.parse(raw), null, 2);
console.log(formatted);
JSON.stringify's third argument sets the indent — use 2 for two spaces or '\t' for tabs.
Python
import json
raw = '{"user": {"id": 42, "name": "Alice"}}'
formatted = json.dumps(json.loads(raw), indent=2)
print(formatted)
The indent parameter in json.dumps() does the same job. Pass sort_keys=True if you want keys in alphabetical order.
JSON format rules people get wrong
Most JSON errors come down to a handful of syntax mistakes. This table covers the ones that trip people up most often — useful to bookmark if you're writing JSON by hand.
| Rule | Correct | Wrong |
|---|---|---|
| Keys must be double-quoted strings | {"name": "Alice"} |
{name: "Alice"} |
| Strings use double quotes only | {"city": "Paris"} |
{'city': 'Paris'} |
| No trailing comma after last item | [1, 2, 3] |
[1, 2, 3,] |
| No comments allowed | (no comments in JSON) | // this breaks JSON |
| Valid value types | string, number, boolean (true/false), null, object, array |
undefined, functions, dates (as objects) |
The JSON spec is defined by RFC 8259, the authoritative standard from the IETF.
Format vs. minify vs. validate vs. query — what's the difference?
Format / beautify adds indentation and line breaks to make JSON easy for humans to read. Minify strips all whitespace to produce the smallest possible string — ideal for sending over a network or storing in a database. Validate checks whether the JSON is syntactically correct without changing it. JSONPath query lets you extract specific values from a large document using a path expression (like $.user.name) without reading the whole structure manually.
How it works
When you click Format, the tool parses your text using the browser's own JSON engine — the same parser that powers JSON.parse() in every modern browser. It then serializes the parsed object back to a string with your chosen indentation. Because all processing happens in your browser, nothing is ever uploaded to a server. Large files (up to 10 MB) are handled entirely on your device, so they stay private.
When to use a JSON formatter — and when not to
- Use it when debugging API responses, config files, or log output that arrives as a single compressed line.
- Use it before committing JSON to a repo — readable, consistently indented JSON is much easier to review in a diff.
- Use it when you hit an error like
Unexpected tokenand need to find the bad line fast. - Skip it if your file is JSON5, JSONC, or JSON with Comments — those allow single quotes and comments, which standard JSON doesn't. Use a dedicated JSON5 parser instead.
- Skip it if you need schema validation (checking that fields have the right types and required keys exist) — that's a job for JSON Schema tools, not a formatter.
Related tools you might need
- JSON Beautifier - Format, Validate & Minify JSON Online — focused on readable output with syntax highlighting.
- JSON Minifier - Compress & Minify JSON Online (Free) — strip whitespace and shrink payload size.
- JSON Validator - Check & Fix JSON Errors Online (Free) — just want to know if your JSON is valid? Start here.
- JSON Viewer - View, Format & Validate JSON Online (Free) — explore large documents in an interactive tree view.
- JSON Pretty Print - Format & Beautify JSON Online (Free) — fast pretty-printing with a focus on readability.
- JSON to YAML Converter - Convert JSON to YAML Online (Free) — switch to YAML when you need comments or a cleaner config format.
Paste your JSON above and get a clean, readable result in one click — no signup, no upload, no wait.