What “formatting JSON” actually does
JSON from an API or a log file is often minified: the entire document squeezed onto one line with no spaces. It is still valid JSON, just unreadable. Formatting (also called pretty-printing or beautifying) expands it back onto indented lines so you can see the structure: objects nested in objects, arrays of items, and where each one ends.
The word is sometimes confused with validating, and the two usually travel together. Validation answers “is this legal JSON?”, formatting answers “can a human read it?”. Good formatters do both in one pass: if your JSON has a syntax error, the formatter stops and points at the line instead of silently producing garbage.
Method 1: Free online formatter (fastest)
For a one-off conversion, an online formatter is the fastest route — no installs, no code. Prefer one that runs entirely in your browser (client-side) so your data never leaves your device; this matters if the JSON contains tokens, emails, or anything sensitive.
- Paste your JSON into the formatter (or drop a .json file).
- Hit Format: the tool indents the document, colors the syntax, and flags any errors with a line number.
- Copy the formatted output back into your editor, or use the Minify button if you need the compact version for production.
Method 2: Your code editor (daily habit)
If you touch JSON regularly, formatting inside your editor is one keystroke. In VS Code, open the .json file and press Shift+Alt+F (Windows/Linux) or Shift+Option+F (Mac) — “Format Document”. VS Code can also format on save if you enable Editor: Format On Save.
Most editors need a plugin for advanced JSON work, but basic formatting is built into VS Code, Sublime Text (via packages), and JetBrains IDEs out of the box.
Method 3: Terminal command (repeatable)
When the JSON lives in a file and you want the same result every time — in a script, a deploy step, or just quickly at the command line — a one-liner beats clicking around.
# Pretty-print data.json to the terminal
python3 -m json.tool data.json
# Write the formatted version to a new file
python3 -m json.tool data.json > data.pretty.json
# Same idea with jq, if you have it installed
jq . data.jsonpython3 -m json.tool also validates: it exits with an error and a line number when the file is not valid JSON, which makes it a quick gate in scripts.
Pretty-print vs minified: when to use which
Pretty-printed JSON is for humans: debugging, config files you edit by hand, examples in documentation. Minified JSON is for machines: API responses, files shipped to production, anything where bytes and parse speed matter.
Convert between the two freely — it is the same data either way. Just never hand-edit the minified version; expand it first, make your change, then minify again if the consumer needs it compact.
Common errors that formatting reveals
Nine times out of ten, a formatter “failing” is the most useful thing it can do. These are the culprits it keeps finding:
- Trailing commas — {"a": 1,} is illegal in JSON (fine in JavaScript). Delete the comma before the closing bracket.
- Single quotes — JSON strings need double quotes. Replace 'value' with "value".
- Comments — // and /* */ are not part of JSON. Strip them, or switch the file to JSONC/JSON5 if your tool supports it.
- Unquoted keys — {name: "x"} needs {"name": "x"}.
- Copy-paste damage — smart quotes from chat apps and docs (“ ”) are not valid quote characters; replace them with straight quotes.
Next step: turn formatted JSON into a spreadsheet
Once your JSON is readable and valid, the next move is often getting it into a spreadsheet — and that is exactly what our free converter does: it flattens your JSON into clean, spreadsheet-ready CSV in seconds, with the same no-upload privacy.
Related guides
- How to Convert CSV to JSON: 3 Reliable Methods (2026 Guide)
- Can You Convert JSON to CSV? Yes — What to Know Before You Do (2026 Guide)
- How to Convert a JSON File to CSV: Uploads, Excel, and the Command Line (2026 Guide)
- What Is the Best Tool for Converting JSON to CSV? 6 Options, Tested (2026 Guide)
- How to Turn JSON into CSV in Under a Minute: The Fastest Way for Every Situation (2026 Guide)
- What Is a JSON to CSV Converter Online Tool? How to Pick a Good One (2026 Guide)
- How Can I Convert a JSON File to a CSV File Online? (2026 Guide)
- How to Flatten JSON to CSV: What the Toggle Actually Does (2026 Guide)
- How to Make CSV from JSON: 7 Decisions That Turn Raw Data into a Working File (2026 Guide)
- How Do I Convert JSON to CSV in VS Code? 4 Ways, From Click to One Keypress (2026 Guide)
- How to Flatten the JSON Data: Explode, Join, or Leave It Nested (2026 Guide)
- Is There a Way to Convert JSON to CSV? Yes — 5 Ways, Pick by Your Situation (2026 Guide)
- How to JSON to CSV Online: Do It in This Tab in 30 Seconds (2026 Guide)
- JSON to CSV Converter Download: What You Should Actually Download (2026 Guide)
- Convert Large JSON to CSV Online Free: How Big Is Too Big? (2026 Guide)
- What Is a JSON and CSV File? A Beginner's Guide to Both Formats (2026 Guide)
- What Does Flattening a JSON Mean? The Term Explained (2026 Guide)
- What Is JSON to CSV Online? The 3 Words Explained (2026 Guide)
- What Is JSON to CSV Converter Online? Anatomy of the Tool (2026 Guide)
- Convert JSON to CSV Locally: Keep the File on Your Machine (2026 Guide)
- What Are Ways to Convert JSON to CSV Locally? 6 Methods, Compared (2026 Guide)
- Why Your CSV Opens in One Column in Excel, and How to Fix It (2026 Guide)
- Why Your CSV Shows Weird Characters in Excel, and How to Fix the Encoding (2026 Guide)
- Why Excel Drops the Leading Zeros From Your CSV Codes, and How to Keep Them (2026 Guide)
- Why Excel Changes Your CSV Dates, and How to Keep Them (2026 Guide)
- Why Saving Your CSV in Excel Changes It, and How to Keep the Original Safe (2026 Guide)
- Why Excel Won't Open Your Big CSV File, and What to Do Instead (2026 Guide)
Frequently asked questions
Is formatting the same as validating JSON?
No, but they overlap. Validation checks whether your JSON follows the syntax rules; formatting rewrites it with indentation and line breaks so humans can read it. Most formatters validate first — they will not format a document with a syntax error, which is why a failed format usually means invalid JSON.
Will formatting change my data?
No. Formatting only changes whitespace: indentation, line breaks, and spaces. Keys, values, order, and types stay exactly the same — unless you explicitly turn on extras like key sorting, which some tools offer as a separate option.
What does “Unexpected token” mean when I format JSON?
It means the parser hit a character it cannot place — almost always a trailing comma, a single-quoted string, an unquoted key, or a smart quote pasted from a chat app. The error message usually includes a position; fix that spot, format again, and the next error (if any) will show up.
Can I format JSON without installing anything?
Yes. Use a free online formatter that runs in your browser, or the one-liner python3 -m json.tool if Python is already on your machine. VS Code also formats .json files out of the box with Shift+Alt+F.
Is it safe to paste JSON into an online formatter?
Usually, but pick a formatter that processes everything in your browser (client-side) — then nothing is uploaded anywhere. If the JSON contains API keys, personal data, or anything you would not email, use your editor or the terminal command instead.
What is minified JSON?
JSON with all unnecessary whitespace removed: the whole document on one line. APIs and production files use it because it is smaller and parses slightly faster. It is valid JSON — just not meant for human eyes. Any formatter can expand it back to the readable version.
Does formatting work on huge JSON files?
Yes, with limits. Browser-based formatters handle a few megabytes fine; beyond that they can freeze the tab — format locally with python3 -m json.tool or jq instead, which stream through large files without breaking a sweat.
JSON formatted and ready?
Turn that clean JSON into a spreadsheet-ready CSV in seconds — free, private, no sign-up.
Open the JSON to CSV converter