JSON Formatter
Validate and pretty-print JSON.
About JSON Formatter
JSON Formatter and Validator
Paste JSON, minified or messy, and the formatter checks that it parses, then returns it with 4-space indentation and one key per line. If the input isn't valid JSON, you get an error and no output.
JSON Rules That Trip People Up
JSON (RFC 8259) looks like JavaScript, but it's stricter. These inputs fail:
- Single quotes: strings and keys need double quotes.
{'a': 1}is invalid. - Trailing commas:
[1, 2, 3,]is invalid. - Comments: JSON has no
//or/* */comments. Config formats like JSONC and JSON5 allow them, but standard parsers reject them. - Unquoted keys:
{name: "x"}is a JavaScript object literal, not JSON. - undefined, functions or dates: JSON values are strings, numbers, booleans,
null, arrays and objects. Dates travel as strings, usually in ISO 8601 format.
What the Output Looks Like
- Keys keep their original order.
- If an object repeats a key, only the last value survives.
- Non-ASCII characters come back as escape sequences, so
"café"prints as"caf\u00e9". Both forms decode to the same text.
Where You Meet JSON
- APIs: most REST APIs send and receive JSON. Pretty-printing a response makes nested fields and arrays easy to follow.
- Config files:
package.json,tsconfig.json, VS Code settings and many cloud policy documents. - Logs: structured loggers write one JSON object per line, which you can paste here one at a time.
On the command line, jq . does the same job: curl -s https://api.example.com/items | jq .