Home → JSON Formatter with Custom Styles
Format JSON with sorted keys, aligned values, and custom indentation options.
Format JSON with sorted keys, aligned values, and custom indentation options. This tool runs entirely in your browser — no data is ever sent to a server. Free to use, no account required.
The formatter offers four indentation styles, each suited to different coding environments and team conventions.
The most popular style, used by JSON.stringify, Node.js, and most JavaScript linters. 2-space indentation balances readability with vertical compactness, producing clean output without excessive line height.
4-space indentation matches Python and Java conventions. Tab indentation is preferred by editors configured with tab settings and produces smaller files when tabs are displayed wider than spaces.
Beyond indentation, the formatter offers key sorting and compact output to meet different workflow requirements.
Sorting keys alphabetically makes large JSON documents easier to scan and produces consistent diffs in version control — two JSON files with identical data in different key order will diff as identical when both are sorted.
Removing all whitespace produces the smallest possible JSON string, ideal for API responses, localStorage, and network transmission where file size matters more than human readability.
Different projects, languages, and tools prefer different JSON formatting conventions. Here's a reference for the most common styles used across the industry.
{
"name": "Alice",
"roles": [
"admin",
"user"
]
}
{
"name": "Alice",
"roles": [
"admin",
"user"
]
}
{
"name": "Alice",
"roles": [
"admin",
"user"
]
}
{"name":"Alice","roles":["admin","user"]}
| Context | Preferred Indent | Notes |
|---|---|---|
| JavaScript/TypeScript | 2 spaces | Airbnb, Google style guides |
| Python | 4 spaces | PEP 8 inspired |
| Java/Kotlin | 4 spaces | Standard IDE default |
| Go | Tab | gofmt standard |
| Ruby | 2 spaces | Ruby community standard |
| Rust | 4 spaces | rustfmt default |
| config files (JSON) | 2 spaces | tsconfig.json, .prettierrc |
| API production | Compact | Smallest payload size |
Explore more tools: All JSON Tools | Validator | Pretty Print | JSON Diff