JSON Formatter
Validate, format, and minify JSON with syntax highlighting.
About this tool
JSON Formatter parses any JSON document, validates it against the RFC 8259 grammar, and reformats it with consistent indentation and syntax highlighting. Paste output from an API response, a configuration file, or a log line — invalid JSON gets an inline error with the exact line and column of the parse failure; valid JSON gets pretty-printed with collapsible objects and arrays so you can navigate large structures without scrolling forever.
Beyond pretty-print, the tool can minify the JSON (strip every avoidable byte for transit), sort keys alphabetically (useful for diffing two configs), escape the whole value as a JSON-in-string (for embedding in another JSON payload), and unescape back. Everything runs locally in your browser — no payload ever crosses the network, so it is safe for API responses that contain tokens or PII.
When to use this tool
- API debugging. Drop a curl response into the formatter to make a wall of compact JSON readable.
- Config-file diffs. Sort both files by key, then compare — random key ordering causes noisy diffs otherwise.
- Validation before deploy. A typo in a CI YAML often hides as malformed JSON inside a string; paste the inner JSON to confirm it parses.
- Embedding JSON in JSON. Auto-escape a payload so it can travel as a string field in another JSON document (handy for webhook bodies in templates).
What our validator catches
RFC 8259 disallows trailing commas, comments, and unquoted keys — common JS-flavoured conveniences. We honour the spec strictly so the JSON you copy out of our formatter is valid everywhere. If you need to format JSON5 or JSONC (with comments, trailing commas), do a preliminary "strip extras" pass — many editors do this automatically when saving as.json.
Frequently asked questions
Why does my JSON with trailing commas fail to parse?
{"a": 1,} is valid in JavaScript but invalid JSON. The same goes for single-quoted strings, unquoted keys, and // comments — those are JS conveniences that the JSON spec deliberately excluded for cross-language portability. If you need a relaxed format, look at JSON5 or JSONC; for strict interop, our formatter is right to reject them.
Can I format JSON Lines (NDJSON)?
Does the tool change my keys' order?
How big can the input be?
jq, fx, jless); for the typical "API response that turned out to be 8 MB" case, the browser handles it just fine.