About the JSON Formatter
JSON is the lingua franca of APIs, config files and log exports, but it is unforgiving: one trailing comma, an unquoted key or a stray single quote and the whole document refuses to parse. This tool validates JSON with the exact line and column of the first error, pretty-prints with 2- or 4-space indentation, minifies for compact transport, and optionally sorts object keys alphabetically — useful for producing stable diffs of config files.
The statistics row shows total size, object and array counts, key count and maximum nesting depth, which helps when you are sanity-checking an API response or working out why a config file has become unmanageable. Everything runs in local JavaScript, so API responses containing internal data are safe to paste. For converting JSON to spreadsheets, see the companion JSON to CSV Converter.
How to Use This Tool
Common Use Cases
- Debugging API responses. Paste a one-line response body from curl or browser dev tools and format it to see the structure you're actually dealing with.
- Editing config files. Validate appsettings.json, tsconfig.json or a webhook payload after hand-editing, before an application chokes on it at startup.
- Comparing payloads. Sort keys A–Z on two JSON documents so a text diff shows real differences instead of key-order noise — pairs well with our Text Diff Checker.
- Shrinking payloads. Minify JSON destined for an HTTP body, environment variable or query parameter where every byte counts.
- Reading log entries. Structured logs often store JSON as a single line; format it to make nested error details readable in an incident.
Common JSON Errors Explained
- Trailing comma.
{"a":1,}is invalid JSON, even though JavaScript accepts it. - Single quotes. Keys and strings must use double quotes:
{'a':1}fails. - Unquoted keys.
{a:1}is a JavaScript object literal, not JSON. - Comments. JSON has none —
//or/* */break the parse. Some tools accept “JSONC”, but the standard does not.