How to format JSON: quick answer
Paste valid JSON into a formatter and choose pretty-print or format. The formatter parses the JSON and adds indentation and line breaks without changing the represented data. If the JSON is invalid, validate it first.
Format JSON: quick steps
- Paste valid JSON into the formatter.
- Choose pretty-print or format to add indentation and line breaks.
- Review the formatted structure and copy the result.
If the formatter reports a syntax problem, use the JSON Validator first. Formatting makes valid JSON easier to read; it does not repair invalid JSON.
Use the ToolAlto JSON Formatter to pretty-print or minify valid JSON directly in your browser.
Open JSON Formatter →What is JSON formatting?
JSON formatting, also called pretty-printing or reformatting JSON, adds indentation and line breaks to valid JSON so nested objects and arrays are easier to read. Formatting changes whitespace and presentation, not the underlying JSON values.
How to format JSON online
- Copy your JSON into a JSON formatter.
- Choose the formatting or pretty-print option.
- Review the indented output.
- Copy the formatted JSON where you need it.
To format JSON online, use ToolAlto's JSON Formatter. It parses the input first, then uses standard JSON serialization to produce readable two-space indentation or a compact minified result.
This workflow is useful when you need to format JSON online, turn one-line JSON into readable JSON, or quickly reformat an API response in your browser.
How to reformat JSON
Reformatting JSON is the same basic idea: take valid JSON that may be compressed into one line and turn it into a structured, indented form. This is useful for API responses, configuration files, logs, copied payloads, and code-review tasks.
If the input is not valid JSON, formatting cannot succeed until the syntax problem is corrected. Use the JSON Validator to check it first.
Example: compact JSON versus formatted JSON
Both examples below represent the same JSON data. Compact JSON saves space, while formatted JSON makes each property and array item easier to scan.
Compact JSON
{"name":"ToolAlto","free":true,"tools":["json","pdf"]}Formatted JSON
{
"name": "ToolAlto",
"free": true,
"tools": [
"json",
"pdf"
]
}Formatting changes whitespace and indentation, not the represented values. Try the same example in the JSON Formatter to see the result.
Why format JSON?
Readable JSON makes it easier to find a property, understand nesting, compare values, spot unexpected data, and review API responses. Formatting is especially useful when a JSON response has been copied as a single long line.
What if JSON formatting fails?
A formatter cannot pretty-print invalid JSON. Common problems include a missing comma, an unmatched brace or bracket, an unquoted property name, a trailing comma, or incorrect quotation marks. If formatting fails, validate the JSON before debugging the application that produced it.
- Missing comma: properties or array items need the required separators.
- Wrong quotes: JSON strings and property names use double quotes.
- Trailing comma: JSON does not allow an extra comma before a closing brace or bracket.
- Unmatched brackets: every object and array must close correctly.
For a dedicated syntax workflow, read How to Validate JSON.
Formatting versus validation
These tasks are related but different. Formatting makes valid JSON easier to read. Validation checks whether the text can be parsed as JSON. A useful workflow is to validate first when you suspect a syntax problem, then format the valid result for inspection.
When should you minify JSON?
Minification removes unnecessary whitespace and creates a compact representation. It can be useful when you need a one-line value or want to reduce text overhead. Keep a formatted copy when people need to review or edit the data.
Does formatting change JSON data?
For valid JSON, changing whitespace and indentation does not change the represented values. A formatter should not be used as a substitute for editing the data itself.
FAQ
What is a JSON formatter?
A JSON formatter takes valid JSON and adds readable indentation and line breaks.
How do I format JSON online?
Paste valid JSON into a browser-based JSON formatter and choose the format or pretty-print option. ToolAlto's JSON Formatter can format valid JSON directly in your browser.
Can formatting fix invalid JSON?
No. Invalid syntax must be corrected before standard JSON parsing and formatting can succeed.
What does pretty-print JSON mean?
Pretty-printing means adding indentation and line breaks to valid JSON so its structure is easier to read.
Can I reformat JSON that is on one line?
Yes. If the one-line text is valid JSON, a formatter can turn it into an indented, readable representation.
What indentation does ToolAlto use?
ToolAlto's formatter uses two spaces for formatted output and can also produce minified JSON.
Is ToolAlto's JSON Formatter free?
Yes. It is free to use in a browser without an account.