JSON Formatter & Validator — Beautify, Minify, Sort
Paste any JSON to beautify (pretty-print), minify, validate syntax, or sort keys alphabetically. Everything runs locally in your browser — your data is never uploaded anywhere.
🧩 JSON Formatter
Privacy note: This tool runs entirely in your browser. Your JSON data is never uploaded, logged, or transmitted to SmartUtilz or any third party — safe to use with API responses, config files, or other sensitive data.
How JSON Formatting Works
JSON (JavaScript Object Notation) is the universal data exchange format for web APIs, configuration files, and modern databases. This tool uses your browser's native JSON.parse() and JSON.stringify() functions to parse, validate, and re-serialize your data:
- Beautify — re-indents with 2-space nesting so deeply nested structures are readable
- Minify — strips all whitespace to produce the smallest possible payload size
- Validate — parses the JSON and reports the exact syntax error (and position) if it's invalid
- Sort Keys — recursively sorts all object keys alphabetically, useful for diffing two JSON files
Step-by-Step Worked Example
Suppose you paste this minified, hard-to-read API response:
{"name":"SmartUtilz","tools":30,"free":true,"categories":["finance","health","dev"]}
Clicking Beautify re-indents it to:
{ "name": "SmartUtilz", "tools": 30, "free": true, "categories": [ "finance", "health", "dev" ] }
The stats panel also shows this JSON has 7 total keys/values tracked recursively (including array items), an original size, and how much smaller the minified version is — useful for judging API payload efficiency.
Common JSON Syntax Errors
| Error | Example (invalid) | Fix |
|---|---|---|
| Trailing comma | {"a":1,} | {"a":1} |
| Unquoted key | {a:1} | {"a":1} |
| Single-quoted string | {'a':'b'} | {"a":"b"} |
| Mismatched brackets | {"a":[1,2} | {"a":[1,2]} |
| Comment (not valid JSON) | {"a":1 // note} | Remove the comment |