How to Format JSON (Beautify, Indent and Minify)
Formatting JSON means adding indentation and line breaks so the structure becomes visible. It changes nothing about the data — only how it is laid out. This guide covers what happens under the hood, what to do when formatting fails, and how to do it safely in the browser.
What JSON formatting actually does
A formatter parses the text into an in-memory structure and then serialises it again with whitespace rules applied: one member per line, a fixed indent per nesting level, and a space after each colon. Because it round-trips through a parser, the output is guaranteed to be valid — and invalid input cannot be formatted at all.
Minifying is the same operation with the whitespace rules switched off. Formatting and minifying are lossless and fully reversible; neither adds, removes or reorders data.
Before and after
{"order":{"id":"A-9931","total":249.9,"items":[{"sku":"TS-01","qty":2},{"sku":"TS-04","qty":1}],"paid":true}}{
"order": {
"id": "A-9931",
"total": 249.9,
"items": [
{ "sku": "TS-01", "qty": 2 },
{ "sku": "TS-04", "qty": 1 }
],
"paid": true
}
}How to format JSON online
Format JSON in your browser
No installation, no account and no upload — the work happens locally on your machine.
- 1
Open the formatter
Open the TheToolSera JSON Formatter in any modern browser.
- 2
Paste your JSON
Paste the raw text into the input pane, or drop a .json file onto it.
- 3
Choose an indent
Pick 2 spaces, 4 spaces or tabs. Two spaces is the common default for web projects.
- 4
Format
The output pane updates immediately with indented, syntax-highlighted JSON.
- 5
Fix any error
If the input is invalid, the line and column of the first problem is reported. Correct it and formatting resumes.
- 6
Copy or download
Copy the result to your clipboard, or download it as a .json file.
JSON Formatter
Format, minify, sort keys and fold nested nodes — everything runs client-side.
Choosing an indent width
| Indent | Best for | Trade-off |
|---|---|---|
| 2 spaces | Web projects, package.json, most style guides | Deep nesting stays readable |
| 4 spaces | Config reviewed by humans, printed documentation | Wide structures wrap on narrow screens |
| Tabs | Teams that let each developer set their own width | Rendering varies between tools |
| Minified | Network payloads, storage, caching | Unreadable without a formatter |
Formatting in an editor or terminal
# Python (no dependencies)
python -m json.tool input.json > pretty.json
# jq
jq . input.json > pretty.json
# Node.js
node -e "console.log(JSON.stringify(require('./input.json'), null, 2))"In VS Code, Shift+Alt+F (Shift+Option+F on macOS) formats the open JSON document. Prettier applies the same rules on save across a whole repository.
Why formatting fails
A formatter refuses to work on invalid JSON, which is genuinely useful — the failure tells you the file is broken. These are the causes you will hit most often:
Trailing comma
A comma after the last member of an object or array. Remove it.
Single quotes
'name' must be "name". JSON only accepts double quotes.
Unquoted keys
{ name: "Ada" } is a JavaScript literal, not JSON.
Copied console output
Browser consoles print previews with ellipses and object placeholders. Copy the raw response body instead.
Concatenated documents
Two objects pasted back to back need to be wrapped in an array, or split into separate lines (NDJSON).
If a formatter silently "fixes" your input, check what it changed. Repairing malformed JSON is a different operation from formatting, and it can guess wrong on ambiguous input.
Best practices
- Commit formatted JSON to version control — diffs become line-level and reviewable
- Serve minified JSON in production and let clients format it for display
- Sort keys before diffing two documents so ordering noise disappears
- Never paste secrets, tokens or customer data into an online tool that uploads to a server
That last point is why every TheToolSera tool runs entirely in the browser tab: your JSON is parsed by your own machine and never sent anywhere.
Frequently asked questions
Does formatting JSON change the data?
No. Only whitespace changes. Keys, values, types and array order are identical before and after.
How do I format JSON without uploading it?
Use a browser-based formatter that parses locally. TheToolSera JSON Formatter never transmits your input — it is processed in the page itself.
What is the difference between beautify and minify?
Beautify adds indentation and newlines for humans; minify strips all optional whitespace for machines. Both produce equivalent data.
Can I format a very large JSON file in the browser?
Yes, up to the memory available to the tab. Files of a few hundred megabytes are usually better handled with jq on the command line.
Put this into practice
JSON Formatter runs entirely in your browser — no upload, no account, no limits.
Open JSON FormatterRelated tools
Related guides
What Is JSON? A Plain-English Guide
JSON explained without jargon: what it is, how the syntax works, which data types it supports, where it is used and how it differs from JavaScript objects.
Common JSON Errors and How to Fix Them
Decode the JSON parse errors you actually hit: unexpected token, trailing comma, unterminated string, BOM issues and duplicate keys — with the fix for each.
JSON vs XML: Which Format Should You Use?
A practical JSON vs XML comparison: syntax, size, parsing speed, schemas, comments, attributes and metadata — plus clear guidance on which format fits which job.
How to Compress Images for the Web
A practical guide to image compression: lossy vs lossless, choosing quality levels, resizing before compressing, format choice, and compressing images in your browser.
CSV vs JSON: Choosing the Right Data Format
Compare CSV and JSON on structure, nesting, file size, streaming, typing and tooling, with clear guidance on which to use for exports, APIs and analytics pipelines.
How to Format SQL for Readable, Reviewable Queries
A practical SQL formatting guide: keyword casing, indentation, join and CTE layout, comma placement, and how consistent formatting makes reviews and debugging faster.