Step-by-step
- Copy the JSON from your API response, log file or configuration.
- Paste it into the JSON Formatter, or load a .json file in the workspace.
- Run the formatter. The output uses two-space indentation.
- If an error appears, read the message and fix the JSON before formatting again. The guide on fixing invalid JSON lists the common causes.
- Copy or download the formatted result.
- Use the JSON Minifier when you need to remove the whitespace again for production.
What formatting changes and what it does not
Formatting adds spaces and line breaks. The keys, values and their order stay the same, so formatted and minified JSON describe identical data.
One caution applies to any JavaScript-based JSON tool. Numbers are read as 64-bit floating-point values, so integers above 9,007,199,254,740,991 can lose precision. For example, 12345678901234567890 comes back as 12345678901234567000. If your IDs are that large, store them as strings or check them with a tool that preserves big integers.
Valid JSON in one minute
Most formatting errors come from a few rules that differ from JavaScript objects.
- Keys and strings use double quotes. Single quotes are not valid.
- No trailing comma after the last item in an object or array.
- No comments of any kind.
- Allowed values are strings, numbers, true, false, null, objects and arrays. undefined and NaN are not valid.
Formatting outside the browser
If you prefer a terminal, python -m json.tool file.json and jq . file.json both pretty-print a file. In a browser console, JSON.stringify(value, null, 2) gives the same two-space layout.
Finish the task with DevUtilityKits
Use the relevant online utility, check the result, and continue with your development workflow.
Open JSON Formatter →Open JSON Validator →Open JSON Minifier →