How to Format JSON Online
- Paste your JSON into the text area above. If you're in a different mode, the tool auto-detects JSON and suggests switching to Format JSON mode.
- Choose your options. Select 2-space or 4-space indentation, or minify. Enable “Auto-fix common errors” to repair broken JSON before formatting.
- Copy the result. Click “Copy Clean Text” or press
Ctrl+Kto copy the formatted JSON to your clipboard. You can also download it as a.jsonfile.
What is JSON Formatting?
JSON (JavaScript Object Notation) is a lightweight data format used everywhere — APIs, configuration files, databases, and inter-service communication. In production, JSON is often minified: all whitespace is stripped to reduce file size and network bandwidth. A minified JSON object like {"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]} is efficient for machines but nearly impossible for humans to read or debug.
Formatting (also called “beautifying” or “pretty-printing”) adds indentation and line breaks so that the structure becomes visible. Each nested level is indented, arrays are expanded, and you can immediately see the hierarchy. This makes it far easier to spot missing commas, mismatched brackets, incorrect nesting, or unexpected values.
Common JSON Errors We Auto-Fix
Strict JSON parsers reject input that doesn't follow the spec exactly. But in practice, JSON is often hand-edited or copied from JavaScript code where looser syntax is valid. Our auto-fix handles the three most common issues:
| Error Type | Before | After |
|---|---|---|
| Single quotes | {'key': 'value'} | {"key": "value"} |
| Trailing comma | {"key": "value",} | {"key": "value"} |
| Unquoted keys | {key: "value"} | {"key": "value"} |
JSON Indentation Options
2-space indentation is the most widely used convention. It's the default in most JavaScript/TypeScript projects, prettier, and many API documentation tools. It balances readability with compact vertical space.
4-space indentation is preferred by some style guides (including Python's json.dumps default) and in contexts where deeper nesting needs to be more visually obvious. It uses more vertical space but can be easier to scan for deeply nested structures.
Minified (0 spaces) strips all whitespace, producing the smallest possible output. Use this for production payloads, API request bodies, configuration values stored in environment variables, or anywhere file size matters. A minified JSON object can be 30-60% smaller than its prettified equivalent.
Frequently Asked Questions
Is my JSON data sent to a server?
No. Unformat.online processes all JSON entirely in your browser using JavaScript's native JSON.parse() and JSON.stringify(). Your data never leaves your device. Verify by opening the Network tab in DevTools — zero requests are made during formatting.
What's the maximum JSON size I can format?
There is no hard limit. The tool uses native browser APIs which handle multi-megabyte JSON files efficiently. For very large files (10MB+), formatting may take a few seconds depending on your device.
Can I format JSON from an API response?
Yes. Copy the raw API response body and paste it directly. The formatter handles both minified and partially formatted JSON. If the response contains non-standard syntax (like JavaScript objects with unquoted keys), enable auto-fix mode.