๐งฉ JSON Formatter
Beautify messy or minified JSON to make it readable, or minify it to save space. Invalid JSON is validated and the parse error is shown. Useful for inspecting an API response, reviewing a config file, or checking logs while debugging.
How to use
- Paste the JSON you want to format or minify into the input box.
- Choose an indent width (2 or 4 spaces).
- Click "Format" or "Minify" to see the result. Any syntax error is shown right there.
- Click "Copy" to copy the result to your clipboard.
How the calculation works
JSON (JavaScript Object Notation) represents data by combining objects โ key/value pairs in {} โ and arrays in []. It is specified in RFC 8259. This tool parses your input with the browser's built-in JSON parser (JSON.parse). If it is valid, formatting writes it back out with the indentation you choose; minifying writes the same data on a single line with no whitespace. Whitespace in JSON carries no meaning except as a separator, so neither operation changes the data. If the syntax is invalid, parsing fails and the error is shown. Common causes are a trailing comma after the last element, single-quoted keys, unquoted keys, and comments โ all things JavaScript tolerates but JSON does not.
Worked example
Formatting this one-line JSON with two-space indentation {"a":1,"b":[1,2]} becomes { "a": 1, "b": [ 1, 2 ] } By contrast, {"a": 1,} has a trailing comma, which is invalid JSON and produces an error.
Things to be aware of
- Trailing commas, single quotes and comments are not allowed in JSON.
- Formatting or minifying resolves duplicate keys to the last value and may normalise number notation (1.0 โ 1).
- Integers beyond the range JavaScript numbers represent exactly (about 9 quadrillion) are rounded.
- Your JSON is processed in the browser and never sent anywhere.
FAQ
Does it tell me about JSON syntax errors?
Yes โ if you enter invalid JSON, the parse error is displayed.
Can I choose the indent width?
Yes โ choose between 2-space and 4-space indentation.
Is this useful for checking an API response?
Yes โ paste a single-line API response and format it to see the structure clearly.
When would I want to minify JSON?
Useful for shrinking a config file or request payload, or when you need the data as a single-line JSON string.
Is my JSON sent to a server?
No, formatting, minifying, and validation all happen in your browser and nothing is sent externally.