How to Beautify & Format JSON Online — Pretty Print, Indent & Minify
Raw JSON from an API, database dump, or log file is usually a single compressed line with no whitespace — nearly impossible to read. Beautifying JSON adds consistent indentation so the structure becomes instantly visible. This guide explains how to beautify JSON online in seconds, when to use 2-space vs 4-space indent, how to minify it back for production, and how to fix common formatting errors along the way.
1 paste
Paste compressed JSON → get readable formatted output instantly
2 or 4
Space indent — 2 is standard in JS/JSON, 4 is common in Python ecosystem
0 bytes
Sent to any server — all formatting happens in your browser
What Does Beautifying JSON Mean?
Beautifying (also called pretty-printing or formatting) JSON means converting a compressed single-line JSON string into a multi-line, indented structure. The JSON data itself does not change — only the whitespace is added to make it human-readable.
Raw compressed JSON vs beautified output
Compressed — impossible to read or debug
{"id":42,"name":"Alice Smith","email":"alice@example.com","roles":["admin","editor"],"address":{"street":"123 Main St","city":"London","country":"UK","postcode":"EC1A 1BB"},"settings":{"theme":"dark","notifications":true,"language":"en"}}Beautified — structure, nesting, and values instantly visible
{
"id": 42,
"name": "Alice Smith",
"email": "alice@example.com",
"roles": [
"admin",
"editor"
],
"address": {
"street": "123 Main St",
"city": "London",
"country": "UK",
"postcode": "EC1A 1BB"
},
"settings": {
"theme": "dark",
"notifications": true,
"language": "en"
}
}How to Beautify JSON Online — Step by Step
Copy your raw JSON
From an API response (Postman, browser DevTools, curl output), a database dump, a log file, or any other source. It can be a single long line, partially formatted, or even slightly broken.
Open the JSON Beautifier
Go to unblockdevs.com/json-beautifier. No login or account required. Your data stays in your browser — nothing is sent to any server.
Paste and format
Paste the JSON into the left panel. The tool validates and formats it instantly. If there are syntax errors (trailing commas, unquoted keys), the auto-fix feature corrects them automatically.
Choose indent level
Switch between 2-space and 4-space indentation depending on your team's convention. The output updates immediately.
Copy or download
Click Copy to copy the formatted JSON to your clipboard, or Download to save as a .json file. Use it in your code editor, share with teammates, or add to your project.
Beautify JSON instantly — no setup
2-Space vs 4-Space vs Tab Indent — Which to Use?
The indent size is a style preference, but ecosystem conventions are strong. Using the wrong indent size breaks consistency with your team's linter and editor settings.
2-space indent (most common)
Standard in JavaScript, TypeScript, JSON config files (package.json, tsconfig.json, .eslintrc), and most Node.js projects. JSON.stringify(obj, null, 2) is the idiomatic JS pretty-print call. Prettier and ESLint default to 2 spaces.
4-space indent
Common in Python projects (PEP 8 for Python code — often carried over to JSON configs), Java, C#, and .NET ecosystems. Preferred in many enterprise style guides. VS Code's default for JSON files is 4 spaces.
Tab indent
Preferred by some teams for accessibility (tab width is user-configurable in editors). Some project configs (Go, Makefile-adjacent tooling) use tabs. Less common in JSON specifically. JSON.stringify(obj, null, "\t") produces tab-indented output.
Compact (no indent)
Used for production: API payloads, localStorage, cookies, Kafka messages, and any case where wire transfer size matters. Removing all whitespace from a large JSON response can reduce transfer size by 20-40%.
const data = {
user: { id: 42, name: 'Alice' },
roles: ['admin', 'editor'],
};
// 2-space (JavaScript standard)
JSON.stringify(data, null, 2);
// 4-space (Python / enterprise convention)
JSON.stringify(data, null, 4);
// Tab indent
JSON.stringify(data, null, ' ');
// Compact (production / wire transfer)
JSON.stringify(data);
// '{"user":{"id":42,"name":"Alice"},"roles":["admin","editor"]}'Minify JSON — Compress Back to Production Format
Minifying reverses beautification — it removes all non-essential whitespace to produce the smallest possible JSON string. Use minified JSON for API responses, message queues, cache storage, and any performance-sensitive transfer.
// Minify by stringifying without a space argument
const minified = JSON.stringify(JSON.parse(prettyJson));
// Or: remove whitespace without parsing (risky — may corrupt string values with newlines)
// Always prefer parse → stringify for safe minification
// Size comparison example:
const pretty = JSON.stringify(data, null, 2); // 312 bytes
const compact = JSON.stringify(data); // 198 bytes
// 37% smaller — significant for large payloads or frequent callsNever manually remove whitespace from JSON
String values in JSON can contain whitespace and newline characters (as \n, \t, etc.) that must not be removed. Always minify JSON by parsing it to a JavaScript object first and re-stringifying — never use a regex or string replace on raw JSON.
Why Your JSON Might Not Beautify — Common Issues
If pasting JSON into a beautifier produces an error instead of formatted output, the input has a syntax problem. The JSON Beautifier auto-fixes many common issues — here are the most frequent ones and their fixes.
Trailing commas — valid in JavaScript, invalid in JSON
Invalid JSON — trailing comma causes parse error
{
"name": "Alice",
"age": 30, ← trailing comma after last property
}Valid JSON — no comma after last property or array element
{
"name": "Alice",
"age": 30
}Single-quoted strings — valid in JavaScript, invalid in JSON
Invalid JSON — single quotes not allowed
{
'name': 'Alice',
'city': 'London'
}Valid JSON — all strings use double quotes
{
"name": "Alice",
"city": "London"
}Unquoted keys — valid in JavaScript objects, invalid in JSON
Invalid JSON — keys must be quoted strings
{
name: "Alice",
age: 30,
city: "London"
}Valid JSON — all keys are double-quoted strings
{
"name": "Alice",
"age": 30,
"city": "London"
}Comments — valid in JavaScript/JSONC, invalid in standard JSON
Invalid JSON — comments not allowed in standard JSON
{
// User settings
"theme": "dark",
/* display preferences */
"language": "en"
}Valid JSON — remove comments before parsing
{
"theme": "dark",
"language": "en"
}When to Beautify JSON in Your Workflow
Debugging API responses
Chrome DevTools shows responses compressed. Copy the response body, paste into the beautifier to see the structure clearly — especially useful for deeply nested objects and large arrays.
Reading error logs
Production logging often serializes error context as compact JSON inline in log lines. Extract the JSON, beautify it, and you can see all nested error fields, stack frames, and metadata at a glance.
Writing JSON config files
package.json, tsconfig.json, .eslintrc, docker-compose.yml overrides, and CI config often include JSON snippets. Beautify to verify the structure before saving.
Reviewing data exports
Database exports, analytics snapshots, and data warehouse dumps often produce compressed JSON. Beautify to audit structure, spot missing fields, and verify data integrity.
Sharing JSON with teammates
Compressed JSON in a Slack message or PR comment is unreadable. Beautify before sharing — or use a link to the beautifier with the JSON pre-pasted.
Generating test fixtures
Test data and mock API responses should be pretty-printed in your repo for readability in code review. Beautify once, commit, and future reviewers can read the data without tooling.