JSON Formatter
Format, validate, sort keys, and minify JSON, with errors pinpointed to line and column.
This JSON formatter validates, pretty-prints, and minifies JSON entirely in your browser tab. Because it is a static page with no backend, your API responses, config files, and payloads are never uploaded anywhere, which is useful when the JSON you are debugging contains tokens, customer data, or anything else you would rather not paste into a random website.
How to use
- Paste or type JSON into the input panel, or click Sample to load an example (the Paste button reads straight from your clipboard).
- Pick 2 spaces, 4 spaces, or Minify with the indentation control. Tick Sort keys to alphabetise object keys at every nesting level.
- If parsing fails, the error pane shows the exact line and column plus a caret pointing at the offending character. Fix the input and the output updates instantly.
-
Copy the result, click Copy minified for a
compact one-liner, or Download it as
data.json.
Worked example: finding a broken comma
Say you paste this config with a trailing comma:
{
"name": "deploy-config",
"retries": 3,
"verbose": true,
} Strict JSON forbids that final comma, so instead of output you get a pinpointed error:
Line 5, column 1: Expected double-quoted property name in JSON at position 58
}
^
Delete the comma after true and the formatter
immediately produces the pretty-printed document, with the
Valid JSON badge confirming it parses.
Sorting keys, minifying, and other notes
- Sort keys for diffing. Two configs that are semantically identical can serialise keys in different orders. Sort both here first, then compare them in the text diff tool to see only real changes. Array order is always preserved. Only object keys are sorted.
- Minify for payloads. The Minify mode and the Copy minified button strip all whitespace, which is handy for embedding JSON in environment variables, curl commands, or query strings.
- Strict parsing. The tool uses the
browser’s native
JSON.parse, so comments, single quotes, unquoted keys, andNaN/Infinityare all rejected. - Huge numbers lose precision. Values beyond JavaScript’s safe integer range (about 16 digits) are rounded during parsing, like in any JS-based tool.
- Large documents. Above roughly 200 kB of output, syntax highlighting switches off to keep typing responsive; formatting, validation, copy, and download all still work.
FAQ
More questions? Browse the full FAQ.
Working with encoded payloads? Decode them first with the Base64 encoder/decoder, or compare two formatted documents side by side with the text diff checker.