JSON Formatter / Minifier
How do I format JSON?
Result
How it is calculated
The tool parses the text as JSON and writes it back out in one of two layouts. In minify mode all optional whitespace is removed, giving the shortest valid text. In pretty mode it adds line breaks and four-space indentation, one key per line. If the text is not valid JSON, for example it has single quotes, a trailing comma or an unquoted key, the tool shows an invalid message instead of guessing a fix. Keys keep their original order, non-ASCII characters and slashes are not escaped. Empty input returns nothing.
Worked example
Input: { "name": "Ada", "age": 36 } with mode set to minify. The text is valid JSON: an object with two keys. The spaces after the braces, colons and commas are not needed, so they are removed. The output is {"name":"Ada","age":36}, 23 characters instead of 28. In pretty mode the same data would be printed on four lines with indentation.
Common mistakes
- Pasting JavaScript object syntax such as
{name: 'Ada'}. JSON needs double quotes around keys and strings. - Leaving a trailing comma after the last item, which is invalid and gives an error.
- Expecting the tool to repair broken JSON. It only reports it as invalid.
- Minifying a file that contains comments. Standard JSON has no comments, so it fails to parse.
About this calculator
This tool takes a block of JSON text and either pretty-prints it — adding indentation and line breaks so nested objects and arrays are readable — or minifies it down to a single compact line, and it flags syntax errors like a missing comma or an unclosed bracket that would otherwise make the JSON fail to parse.
Developers use the pretty-print side constantly when inspecting an API response, a config file, or a webhook payload that arrives as an unreadable single-line string, and use the minify side when preparing JSON to ship in production — smaller payloads mean less bandwidth and faster load times. It's also a fast way to check whether a hand-edited config file or a copy-pasted API response is actually valid JSON before it causes a parsing error somewhere else in the code.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
No calculators found
Comments (0)