How to use JSON Formatter
- Paste or type JSON into the input panel (or click "Load example").
- Choose the indentation style and optionally enable "Sort keys".
- The formatted output appears instantly; fix any error reported with its line and column.
- Copy the result or download it as a .json file.
JSON Formatter features
- Pretty-prints with 2 spaces, 4 spaces, tabs or fully minified output
- Live formatting as you type, with copy and download buttons
- Optional recursive key sorting for diff-friendly, canonical documents
- Precise syntax errors with line, column, a hint and an excerpt of the offending text
- Document statistics: size, key count, nesting depth and value types
- Warns about integers that exceed JavaScript's safe range
JSON Formatter example
Format a minified API response
Input:
{"user":{"id":7,"name":"Layla"},"roles":["admin","editor"],"active":true}Output:
{
"user": {
"id": 7,
"name": "Layla"
},
"roles": [
"admin",
"editor"
],
"active": true
}Frequently asked questions about JSON Formatter
Does my JSON leave the browser?
No. Formatting runs entirely in your browser with the native JSON parser; nothing is uploaded or logged.
Can I format very large files?
Yes — documents up to 2 MB are formatted instantly. For bigger payloads, minify first or split the data.
What does "Sort keys" do?
It recursively orders object keys alphabetically so two documents with the same content produce identical text, which makes diffs and code reviews much easier.
Why does the formatter report an error for my file?
JSON is strict: keys must use double quotes, trailing commas are not allowed and comments are forbidden. The error message shows the line, column and a hint about the likely cause.
Will large integers be changed?
Integers above 2^53 − 1 cannot be represented exactly by JavaScript. The tool warns you when it detects such values so you can keep them as strings.
Technical notes
Parsing uses the browser's native JSON.parse, so the formatter accepts exactly what RFC 8259 allows and nothing more. When parsing fails, the tool converts the engine's error position into a line/column pair and scans the surrounding text for common mistakes such as single quotes, trailing commas, unquoted keys or comments.
Sorting keys re-creates each object with keys in locale-aware order at every nesting level. Arrays are never reordered because their order is part of the data.