About the JSON Formatter
Paste minified or messy JSON to pretty-print it with consistent indentation. The formatter validates as it goes and points to the exact line of any syntax error.
Key features
- Pretty-print with 2 spaces, 4 spaces or tabs
- Instant validation with exact line and column of errors
- Handles multi-megabyte files without freezing
- Syntax highlighting and code folding
- Copy or download the formatted file in one click
- 100% client-side: your JSON never leaves your browser
What is a JSON formatter?
A JSON formatter (also called a JSON beautifier or pretty printer) takes JSON that is hard to read, usually minified into a single long line or inconsistently indented, and rewrites it with a clean, predictable layout: one key per line, nested objects indented, and arrays expanded. The data itself doesn't change; only the whitespace does.
APIs, log files and databases usually emit compact JSON to save bandwidth and storage. That's ideal for machines and painful for humans. Formatting it is the first step in debugging an API response, reviewing a config file, or writing documentation.
Before and after
Here is a typical minified API response:
{"id":42,"user":{"name":"Ada","roles":["admin","editor"]},"active":true,"lastLogin":null}
After formatting with 2-space indentation:
{
"id": 42,
"user": {
"name": "Ada",
"roles": [
"admin",
"editor"
]
},
"active": true,
"lastLogin": null
}
The structure is now obvious at a glance: user is a nested object, roles is an array with two items, and lastLogin is explicitly null.
When to format JSON
- Debugging API responses. Copy a response from your browser's network tab or a
curlcommand and make it readable in seconds. - Reviewing configuration. Files like
package.json,tsconfig.jsonandappsettings.jsonare easier to review and diff when consistently formatted. - Writing documentation. Readable examples make API docs, README files and tutorials far clearer.
- Comparing data. Formatted JSON produces meaningful line-by-line diffs in Git and code review tools.
- Learning a new API. Expanding a sample payload is the fastest way to understand its shape.
Indentation options compared
| Option | Best for | Example line |
|---|---|---|
| 2 spaces | JavaScript/TypeScript projects, deeply nested data | "name": "Ada" |
| 4 spaces | Python, Java, C# projects | "name": "Ada" |
| Tab | Teams that let each developer choose the visual width | →"name": "Ada" |
Formatting errors explained
If the formatter can't parse your input, it reports the exact line and column where parsing failed. These are the usual suspects:
- Trailing comma:
{"a": 1,}. Remove the comma after the last item. - Single quotes:
{'a': 1}. JSON requires double quotes. - Unquoted keys:
{a: 1}. Keys must be strings in double quotes. - Comments:
// note. JSON has no comment syntax. NaN,Infinityorundefined: these are JavaScript values, not JSON.
For messy input from JavaScript code or logs, the JSON Fixer repairs all of these automatically. To check validity without reformatting, use the JSON Validator.
Privacy and performance
The formatter uses your browser's native JSON.parse and JSON.stringify, the same fast engines that power web applications. Nothing is uploaded, so it's safe to format production data, access tokens or customer records. Large files of several megabytes format in well under a second on a modern laptop.
Related tools
Need the opposite? The JSON Minifier strips all whitespace to make payloads as small as possible. To explore a large document interactively, open it in the JSON Viewer. To sort keys alphabetically before formatting, use the JSON Sorter.
How to use the JSON Formatter
- Paste your data into the input box, upload a file, or click Sample to try it out.
- Adjust the options above the editor if you need to (indentation, delimiter, and so on).
- The result appears instantly in the output panel. Any errors are shown with their line and column.
- Click Copy to copy the result, or Download to save it as a file.