What is JSON?
JSON (JavaScript Object Notation) is a text format for structured data built from objects, arrays, strings, numbers, booleans and null. It is defined by RFC 8259 and ECMA-404, is language-independent, and is the default format of web APIs because it is compact, human-readable and easy to parse.
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 (case-insensitive, with one fixed collation rather than your browser's language) so two documents with the same content produce identical text, which makes diffs and code reviews much easier. Keys made of digits are sorted as text, so "10" comes before "9".
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 writes every object with its keys in one fixed, case-insensitive alphabetical order at every nesting level. The tool serialises the sorted output itself, because a JavaScript object always lists integer-like keys such as "10" first. Arrays are never reordered because their order is part of the data.
References
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange FormatThe JSON grammar: objects, arrays, strings, numbers, the three literals, and UTF-8 as the interchange encoding.
- ECMA-404: The JSON Data Interchange SyntaxThe JSON syntax as an Ecma standard, kept in step with RFC 8259.
- Introducing JSONThe original one-page description of JSON with its railroad diagrams.