About this json formatter
JSON Formatter
A JSON formatter takes raw or minified JSON and returns it neatly indented and validated, so you can actually read the data structure. Paste your JSON, and the tool instantly pretty-prints it — and if the input is invalid, it points to the exact line and column where parsing failed.
Developers use it dozens of times a day: inspecting API responses, debugging config files, reviewing webhook payloads, and cleaning up data before pasting it into code or documentation. Minified JSON from a server is a single unreadable line; this tool expands it with your choice of indentation (2 spaces, 4 spaces, or tabs), collapses long structures for scanning, and can also do the reverse — minify formatted JSON back to one compact line for transmission. Validation is strict: it follows the JSON grammar, so trailing commas, single-quoted strings, comments, and unquoted keys are all flagged as errors with a clear message. Everything runs locally in your browser, which matters when the payload contains API keys, tokens, or customer data you should not paste into a random server-side tool.
Working with API URLs? Encode or decode them with HexKit’s free URL encoder — bulk mode and a query-parameter analyzer included.
How to use it
- Paste your JSON into the Input box — minified, formatted, or straight from an API response.
- Choose the Indent style: 2 spaces, 4 spaces, or tabs.
- Click Format to validate and pretty-print the result in the Output box.
- If there is an error, read the message under the input showing the line and column, fix it, and format again. Use Minify to compress valid JSON to one line, or Copy to copy the output.
The method behind it
Frequently asked questions
Why does the formatter reject trailing commas?
Because the JSON specification (ECMA-404 / RFC 8259) does not allow them. Trailing commas are valid in JavaScript object literals, which is why the mistake is so common — but a strict JSON parser must reject them. Remove the comma after the last element and the document becomes valid JSON.
Can I use single quotes or comments in JSON?
No. Valid JSON requires double-quoted strings and has no comment syntax — those belong to JavaScript or to supersets like JSONC and JSON5. If your config file uses comments or single quotes, it is not JSON; convert it to strict JSON first (many editors can do this) before formatting.
Is it safe to paste API responses containing tokens?
Here, yes: the tool runs entirely in your browser and never uploads your input anywhere. That said, treat any formatter as untrusted until you verify this — a server-side formatter would receive a copy of everything you paste, including secrets. When in doubt, redact tokens before pasting.
What is the difference between formatting and minifying?
Formatting adds whitespace (indentation and line breaks) so humans can read the structure; minifying strips all unnecessary whitespace so the payload is as small as possible for transfer over the network. Both represent exactly the same data. Format while debugging, minify before sending.
Why do large numbers lose precision?
JSON numbers are parsed as double-precision floats in JavaScript, which represent integers exactly only up to 2^53 − 1 (9,007,199,254,740,991). IDs larger than that — common with 64-bit database keys — get rounded. APIs often send such IDs as strings instead; if yours does not, be aware the formatted output may show a rounded value.
Worked example
Input (minified, 44 characters):
{"name":"HexKit","tools":9,"free":true}
Clicking Format with 2-space indent produces:
`json { "name": "HexKit", "tools": 9, "free": true } `
The structure is identical — one object with three keys — only whitespace was added. Now introduce a common mistake, a trailing comma:
{"name":"HexKit",}
The validator rejects it: the RFC 8259 JSON specification forbids trailing commas (unlike JavaScript object literals), and the tool reports an error at the position of the unexpected }. Remove the comma and it formats cleanly. This is the fastest way to find the one bad character in a 500-line API response.