How to Format JSON Online
A complete step-by-step guide to formatting, validating, beautifying, minifying, and fixing JSON using JSONFormatter.site — free, instant, and 100% client-side.
Quick Start
Paste your JSON into the left panel, click Format, and copy the result. That's it. For validation, auto-fix, minification, and conversion, continue reading below.
Step-by-Step: How to Format JSON
Follow these four steps to format any JSON string into a clean, readable structure:
- 1
Paste or upload your JSON
Copy your JSON data and paste it into the input panel on the left side of the tool. You can also click Upload to load a .json file from your device, or click URL to fetch JSON directly from any public API endpoint.
- 2
Click Format
Press the Format button to instantly beautify your JSON with proper 2-space indentation and line breaks. Use Minify to compress the JSON instead. Use Validate to check for syntax errors without modifying the output. Use Fix to auto-repair common mistakes.
- 3
Review the output
The formatted JSON appears in the right panel. Toggle between Raw view for the formatted text and Tree view for an expandable, interactive JSON tree structure that makes exploring nested data much easier.
- 4
Copy or download
Click the Copy button to copy the formatted JSON to your clipboard. Click Download to save it as a .json file to your device.
How to Validate JSON Online
Paste your JSON into the tool and click Validate. If the JSON is valid, a green "Valid JSON" status appears instantly. If the JSON has errors, the tool displays the exact line number and a description of the problem.
Enable Auto-validate mode to validate your JSON in real-time as you type — ideal for spotting mistakes while manually editing JSON. Validation checks that your JSON conforms to the RFC 8259 JSON specification, including correct use of double quotes, proper comma placement, and valid data types.
Example: Invalid JSON and its error
// Invalid — trailing comma
{ "name": "Alice", "age": 30, }
// Error: Unexpected token } in JSON at position 27How to Minify JSON
JSON minification removes all whitespace, indentation, and line breaks from JSON, reducing file size to its smallest possible form. Paste your JSON and click Minify. The compressed JSON appears in the output panel, ready to copy or download.
Minified JSON is ideal for production environments — smaller payloads mean faster API responses and reduced bandwidth usage. Use our dedicated JSON Minifier tool for a focused experience.
How to Fix Broken JSON
The JSON Fixer automatically repairs common JSON errors with a single click. Paste your broken JSON, then click Fix. The tool attempts to correct trailing commas, single-quote usage, unquoted keys, and undefined values automatically.
For errors the auto-fix cannot resolve, check the error message for the exact line number and manually inspect the surrounding code.
How to Convert JSON to Other Formats
JSONFormatter.site includes dedicated conversion tools for the most common JSON transformations:
- JSON to YAML — Convert JSON to YAML format. Widely used for Kubernetes configs, Docker Compose, CI/CD pipelines, and Ansible playbooks.
- JSON to CSV — Convert JSON arrays to CSV format for spreadsheet import, data analysis, and reporting.
- JSON to XML — Convert JSON to XML for legacy systems, SOAP APIs, and XML-based data exchange.
Common JSON Errors and How to Fix Them
These are the most frequent JSON syntax errors developers encounter when working with APIs, config files, and data imports:
| Error | Cause | Fix |
|---|---|---|
| Unexpected token ' | Single quotes used instead of double quotes | Replace all single quotes around keys and string values with double quotes |
| Trailing comma | Extra comma after the last item in an array or object | Remove the final comma, or use the auto-fix button |
| Unexpected token } | Missing comma between key-value pairs | Add a comma after each value except the last one |
| Unexpected token u (undefined) | Using undefined — not a valid JSON value | Replace undefined with null, or remove the key entirely |
| Property names must be strings | Object keys are not wrapped in double quotes | Wrap all keys in double quotes: { "key": value } |
| Unexpected token / (comment) | JavaScript-style comments // or /* */ in the JSON | Remove all comments — standard JSON does not support them |
Use the JSON Fixer to automatically correct most of these errors in one click.
Ready to Start?
Try the JSON Formatter now — paste your JSON, click Format, and get clean results instantly. No signup, no data uploaded. Check our frequently asked questions if you have more questions about JSON formatting.
Open JSON Formatter