JSON Formatter: How to Beautify, Validate, and Minify JSON
Format, beautify, and minify JSON instantly with our free online tool. Learn about common JSON errors, when to minify vs beautify, and best practices for working with JSON.
Key Takeaways
- Beautifying adds indentation for readability. Minifying strips whitespace to cut file size by 30-60%.
- Trailing commas, single quotes, and unquoted keys are the three most common JSON parsing failures.
- Our browser-based formatter validates, beautifies, and minifies instantly -- no data leaves your machine.
- Beautify config files in version control (so diffs make sense). Minify API responses and stored payloads.
Format JSON Instantly
Paste or type JSON below to beautify, validate, or minify it. Errors are highlighted with exact line and character positions. Everything runs in your browser.
The Five JSON Errors You Will Hit Every Week
Even experienced developers trip over these constantly. They account for the vast majority of parsing failures.
Trailing commas
Valid in JavaScript, invalid in JSON:
{
"name": "Alice",
"age": 30,
}
The comma after 30 breaks every JSON parser. Remove trailing commas from the last element in every object and array.
Single quotes
JSON requires double quotes. Single quotes are rejected:
{ 'name': 'Alice' }
Unquoted keys
JavaScript allows { name: "Alice" }. JSON does not. Every key must be a double-quoted string.
Comments
JSON has no comment syntax. If you need comments, use JSON5 or JSONC (what VS Code’s settings.json uses), but standard parsers will reject them.
Wrong value types
undefined is not valid JSON. Neither are functions, NaN, or Infinity. Use null instead of undefined.
Invisible characters break parsing too
If your JSON looks correct but still fails, check for invisible characters. Copying from PDFs, Slack, or rich-text editors often introduces zero-width spaces or curly (“smart”) quotes that silently break parsing. Paste into the formatter above to detect them.
When Should You Beautify vs Minify JSON?
Beautify JSON in any file a human reads — config files in version control, documentation, debugging output. Minify JSON for any payload a machine consumes — API responses, stored payloads, network transfers — where stripping whitespace cuts 30-60% of file size with zero semantic change.
| Beautify (Pretty Print) | Minify (Compact) | |
|---|---|---|
| Purpose | Human readability | Machine efficiency |
| Whitespace | Adds indentation and newlines | Strips all unnecessary whitespace |
| Size impact | 30-60% larger | Smallest possible |
| Use case | Debugging, config files, docs | API responses, storage, network transfer |
| Readability | Excellent | Nearly impossible for large payloads |
Beautify anything humans read: config files in version control (so diffs are meaningful line-by-line), documentation examples, debugging output.
Minify anything machines consume: API responses, stored payloads, anything sent over a network. Stripping whitespace from a 50 KB response saves 15-20 KB, which compounds at thousands of requests per second. HTTP compression (gzip, Brotli) helps further, but starting smaller is always better.
JSON in Practice
API debugging
Browser DevTools show raw JSON in the Network tab, usually unformatted. Copy the payload, paste it into a JSON Formatter, and get instant syntax highlighting and structure. Pair with a Base64 Decoder for APIs that encode JSON payloads in Base64. For a deeper look at which data format to use in each context, the JSON vs XML vs YAML vs TOML comparison covers the tradeoffs.
Config file errors
ESLint, TypeScript, Prettier, and package managers all use JSON config. When a build fails with a cryptic parse error pointing at your tsconfig.json, paste the file into a validator. It pinpoints the exact character faster than reading the file line by line.
Database storage
Storing JSON in PostgreSQL (jsonb), MongoDB, or DynamoDB? Minify before persisting to reduce storage costs. Validate on the application layer first. Beautify on read for UI display.
Structured logging
JSON Lines (NDJSON) outputs one JSON object per log line. When tailing logs, pipe individual lines through a formatter to make them readable. A browser-based formatter handles ad-hoc debugging faster than building a custom tool.
JSON Lines is not a JSON array
JSON Lines (NDJSON) is a sequence of independent JSON objects separated by newlines. Each line is valid JSON, but the whole file is not. Paste individual lines into a formatter, not the entire file.
What Is JSON Schema Validation?
JSON Schema validation checks that a document’s data matches a defined structure — required fields, allowed types, and value constraints — going beyond syntax to catch semantic errors. A formatter tells you “this is valid JSON.” A schema validator tells you “this is valid data for this application.”
Formatting confirms syntax is valid. It says nothing about whether the data is correct. JSON Schema defines the expected structure — required fields, allowed types, value constraints — and validates documents against it.
A schema might require that a user object always has a string field called email and a number field called age between 0 and 150. If someone sends "age": "thirty", the schema validator catches it before your application code does.
If you work with JSON daily, learning JSON Schema is high-leverage. It catches bugs at the boundary before they propagate.
Use the Formatter
Bookmark our JSON Formatter. Paste your broken payloads. Stop debugging JSON syntax by hand. The HTTP status codes reference and markdown syntax guide are useful companions when building and documenting APIs.
Related tools
JSON Formatter →
Format, validate, and minify JSON instantly — with configurable indentation, error location, and tree view.
Regex Tester →
Test regular expressions live with color-coded match highlighting, capture groups, replace mode, and common presets.
Base64 Encoder/Decoder →
Encode text or files to Base64 or decode Base64 strings back to plain text — real-time, fully in your browser.
AI Token Counter →
Count tokens for GPT-4o, Claude, Gemini, and more. Exact tiktoken counts for OpenAI models, estimates for others, with API cost breakdown.
JWT Decoder →
Decode and inspect JWT tokens — view header, payload, claims, and expiry status without sending data to any server.
URL Encoder/Decoder →
Encode or decode URLs and query string components instantly — supports encodeURIComponent, decodeURIComponent, and full URL encoding.
XML Formatter →
Format, minify, and validate XML online — syntax checking with clear error messages, configurable indent, real-time output.
String Escape / Unescape →
Escape or unescape strings for JSON, HTML, JavaScript, CSV, and SQL — real-time, client-side, zero dependencies.
HTML Formatter →
Format and beautify messy HTML with configurable indent, wrapping, and attribute handling — paste or type, get clean output instantly.
SQL Formatter →
Format, beautify, and minify SQL queries with dialect support for MySQL, PostgreSQL, SQL Server, BigQuery, and more.
Related articles
JSON vs XML vs YAML vs TOML: When to Use Each Format
Compare JSON, XML, YAML, and TOML with real config examples. 70% of APIs use JSON (Postman, 2025) - learn which format fits your use case.
Base64 Encoding Explained: How It Works and Why
Visual step-by-step guide to Base64 encoding. See how text becomes a 6-bit alphabet used in data URIs, JWTs, and email. Adds ~33% size overhead.
API Authentication Methods Compared: OAuth, JWT, API Keys
Compare API authentication methods with real HTTP examples. OAuth 2.0, JWT, API keys, and session tokens explained. 78% of breaches involve weak auth.