JSON Formatter & Validator
Format, validate, and minify JSON instantly. Pretty-print with 2 or 4 space indentation. 100% browser-based.
Paste JSON to format with proper indentation or minify to a single line. Invalid JSON shows the exact error.
What Is JSON and Why Format It?
JSON (JavaScript Object Notation) is the lingua franca of the web. Every API you've ever used almost certainly speaks JSON. It's human-readable in theory — but in practice, minified JSON is a wall of brackets and commas that makes your eyes bleed. That's where formatting comes in.
Pretty-printing JSON adds indentation and line breaks so you can actually see the structure. Nested objects become obvious. Missing commas jump out. A 500-character blob becomes a clear, scannable tree. It's the difference between reading a paragraph with no spaces and reading one with proper formatting.
This tool runs entirely in your browser — your JSON never leaves your device. Paste it in, format or minify, copy the result. No API calls, no data logging, no privacy concerns.
JSON Data Types at a Glance
| Type | Example | Notes |
|---|---|---|
| String | "name": "Alice" | Always double-quoted (not single) |
| Number | "age": 30 | No quotes, supports decimals and negatives |
| Boolean | "active": true | Lowercase true/false only |
| Null | "deleted": null | Lowercase null (not undefined) |
| Array | "tags": ["a", "b"] | Ordered list, mixed types allowed |
| Object | {"key": "value"} | Unordered key-value pairs |
What this means for you: JSON doesn't support comments, trailing commas, single quotes, or undefined. These are the most common reasons JSON fails to parse. If your JSON won't validate, check for these first.
Common JSON Errors and How to Fix Them
| Error | Cause | Fix |
|---|---|---|
| Unexpected token | Single quotes instead of double | Replace ' with " for all keys and string values |
| Unexpected end of input | Missing closing bracket or brace | Count opening/closing pairs — they must match |
| Expected ',' or '}' | Trailing comma after last item | Remove the comma after the last property |
| Unexpected token / | Comments in JSON | Remove // and /* */ comments — JSON doesn't support them |
| Bad escaped character | Unescaped backslash or quote | Escape special chars: \\ for backslash, \" for quote |
| Unexpected token u | undefined value | Replace undefined with null |
Format vs Minify: When to Use Each
Format (pretty-print)
Use during development, debugging, code review, and documentation. Readable structure helps you spot issues. Choose 2-space indent for compact output, 4-space for maximum readability.
Minify (compact)
Use for production APIs, config files, and data transfer. Removes all whitespace to reduce payload size. A 10KB formatted JSON might minify to 6KB — a 40% saving that adds up at scale.
JSON vs Alternatives
| Format | Comments | Human Readable | Best For |
|---|---|---|---|
| JSON | No | Good (when formatted) | APIs, data transfer, config |
| YAML | Yes | Excellent | Config files (Docker, CI/CD) |
| TOML | Yes | Excellent | App config (Cargo, pyproject) |
| XML | Yes | Poor (verbose) | Legacy systems, SOAP, Android |
| Protocol Buffers | Yes (in .proto) | No (binary) | High-performance APIs (gRPC) |
What this means for you: JSON won the API format war because it's native to JavaScript and simple to parse in every language. Use YAML or TOML for config files where you need comments. Use JSON for data exchange.
Related Tools
How to use this tool
Paste your raw JSON into the input area
Click Format to pretty-print or Minify to compress
Copy the result or view syntax-highlighted output
Common uses
- Debugging API responses during development
- Formatting config files for readability
- Minifying JSON payloads to reduce file size
- Validating JSON structure before deployment
Share this tool