Prettify Minified JSON with JSON.stringify
Minified JSON is the same data with whitespace removed. To prettify it, parse the string with JSON.parse and serialize with JSON.stringify(value, null, 2). Docify’s formatter does exactly that in the browser. Load sample fills the compact object {"name":"John Doe","age":30,"email":"john@example.com","address":{"street":"123 Main St","city":"New York","country":"USA"},"hobbies":["reading","coding","gaming"]} and does not run Prettify, Minify, or Validate. Prettify then writes the matching 2-space JSON. Minify writes that same compact line. This is not the older users / Jane Smith / total leftover. Standard JSON only — no comments, trailing commas, or JSON5. Nothing is uploaded.
Production APIs often omit spaces to save bytes. That one long line is still valid JSON if the syntax is correct — it is just hard to inspect. Use the JSON formatter Prettify button, or the same two calls in a console. Load sample fills that leftover compact object and does not run Prettify.
What is Minified JSON?
Minified (or compact) JSON removes insignificant whitespace: spaces, tabs, and newlines that are not inside strings. Parsers ignore that whitespace, so minified and pretty JSON can represent the same value.
Minified JSON (hard to read):
{"name":"John Doe","age":30,"email":"john@example.com","address":{"street":"123 Main St","city":"New York","country":"USA"},"hobbies":["reading","coding","gaming"]}Prettified JSON (2-space indent):
{
"name": "John Doe",
"age": 30,
"email": "john@example.com",
"address": {
"street": "123 Main St",
"city": "New York",
"country": "USA"
},
"hobbies": [
"reading",
"coding",
"gaming"
]
}Why Prettify JSON?
- 🔍Debugging - Spot issues and understand data structure at a glance
- 📖Readability - Make sense of nested API responses
- 👥Code reviews - Share formatted JSON with team members
- 📝Documentation - Include readable examples in docs
How to Prettify JSON in 3 Steps
Step 1: Copy Minified JSON
Copy the compact JSON from an API response, the network panel, or a log. It may be a single line.
Step 2: Parse, then stringify
Paste it into the JSON formatter and click Prettify, or run JSON.stringify(JSON.parse(text), null, 2) in the console. Load sample fills the compact John Doe object and does not run Prettify. Invalid JSON fails at parse time.
Step 3: Copy the pretty text
The output is a new JSON string with 2-space indent. Docify shows it in a plain textarea — copy it; there is no syntax-highlighted preview.
Other ways to prettify
Browser console
Built in, no extra tool: JSON.stringify(data, null, 2)
Command line (jq)
For large files on your machine: jq . file.json
jq is a local filter. The Docify page is a browser paste box, not a replacement for piping multi-megabyte files.
Code editor
Most editors can Format Document on a .json file. That is convenient in a project; the online formatter is for a quick paste when you do not want to save a file.
2 spaces vs 4 spaces
2 spaces (Docify / JSON.stringify space 2):
{
"name": "John",
"age": 30
}4 spaces (JSON.stringify space 4):
{
"name": "John",
"age": 30
}Both are valid JSON. Docify always emits 2 spaces. Use 4 in your own stringify call if a project style guide asks for it.
When to Minify vs Prettify
| Situation | Use | Why |
|---|---|---|
| Production API responses | Minified | Fewer bytes on the wire before compression |
| Development & debugging | Prettified | Easier to read nested objects |
| Config files in a repo | Prettified | Clearer diffs in version control |
| Documentation examples | Prettified | Shows structure to readers |
Pretty JSON is larger because of added spaces and newlines. How much larger depends on nesting. Transport compression (gzip or brotli) often shrinks that whitespace again on the wire.
Prettify JSON in the browser
JSON.parse then JSON.stringify with 2-space indent. Nothing is uploaded.
Open JSON Formatter →FAQ
- What does Load sample Prettify write on the live JSON page?
- Load sample fills the compact object {"name":"John Doe","age":30,"email":"john@example.com","address":{"street":"123 Main St","city":"New York","country":"USA"},"hobbies":["reading","coding","gaming"]} and does not run Prettify, Minify, or Validate. Prettify then writes the matching 2-space JSON. Minify writes that same compact line. This is not the older users / Jane Smith / total leftover. Standard JSON only — no comments, trailing commas, or JSON5.
- Does prettifying change the JSON values?
- Docify prettifies by parsing with JSON.parse and serializing with JSON.stringify(value, null, 2). That restores a canonical JSON text: key order follows the parser, and numbers that do not fit in IEEE-754 may round. Comments and trailing commas never survive because parse rejects them. Load sample Prettify of the John Doe object keeps age as the number 30 and the hobbies array as three strings.
- How does Docify add indentation?
- The Prettify button always uses two spaces. There is no 4-space or tab control, and the output textarea is plain text — not a syntax-highlighted editor. Load sample fills the compact John Doe object and does not run Prettify.
- How do I prettify JSON in the browser console?
- If you already have a JavaScript value named data, run JSON.stringify(data, null, 2). If you have a string, parse it first: JSON.stringify(JSON.parse(text), null, 2).
- How do I prettify JSON in Python?
- Use json.dumps(data, indent=2) on a parsed object, or json.dumps(json.loads(text), indent=2) on a string. That is the same parse-then-serialize idea as the browser tool.