What is JSON?
JSON (JavaScript Object Notation) is a lightweight text-based data format used to exchange structured data between applications. It supports six data types: strings (`"hello"`), numbers (`42`, `3.14`), booleans (`true`, `false`), `null`, objects (`{}`), and arrays (`[]`). JSON is the standard format for REST APIs, configuration files, and web application data exchange.
What is a JSON formatter?
A JSON formatter takes raw or minified JSON and reorganizes it with consistent indentation (typically 2 or 4 spaces), line breaks after each key-value pair, and aligned braces and brackets. It also validates syntax and highlights errors at the exact line and column where they occur. This tool uses `JSON.stringify(data, null, 2)` internally to produce standard 2-space indented output.
Is my JSON data private?
Yes. This tool runs entirely in your browser using client-side JavaScript. No JSON data is transmitted to or stored on any server. You can verify this by opening your browser's Network tab — no requests are made when you format or validate JSON. This makes it safe for API keys, tokens, and internal configuration data.
What does minify actually do?
Minification removes all whitespace, line breaks, and indentation to produce the smallest possible valid JSON string. For example, a 2,400-byte formatted payload typically reduces to around 800 bytes after minification. This is ideal for API responses, localStorage values, and URL parameters where size matters. If your JSON is embedded in an authentication token, decode it first with our
JWT Decoder.
What does the fix JSON button do?
The `Fix JSON` button appears when your input contains syntax errors. It automatically repairs trailing commas (`{"a": 1,}`), converts single quotes to double quotes (`'key'` → `"key"`), wraps unquoted keys in double quotes (`name:` → `"name":`), removes JavaScript-style comments, replaces smart quotes from word processors, inserts missing commas between values, and balances unclosed brackets. The corrected JSON replaces your input so you can then format or minify it.
Can the formatter handle large JSON files?
Yes. Files over 1MB are automatically processed in a Web Worker thread so the editor remains responsive. The practical limit depends on your device's available memory — most modern browsers handle files up to 50-100MB without issues. For files larger than 2MB, the stats panel skips the deep structure analysis to maintain performance.
Why does JSON validation fail?
The most common causes are: keys without double quotes (`{name: "Jane"}`), trailing commas after the last item (`{"a": 1,}`), single quotes instead of double quotes (`{'name': 'Jane'}`), JavaScript comments (`// comment`), and unescaped special characters inside strings. The error message shows the exact line and column number. Try the `Fix JSON` button to resolve most of these automatically.
Does JSON support comments?
Standard JSON (RFC 8259) does not allow comments. However, JSONC (JSON with Comments), used by VS Code settings files, supports `//` single-line and `/* */` multi-line comments. If you paste JSONC into this tool, the `Fix JSON` button strips all comments to produce valid standard JSON. Minifying also removes any comments automatically.
What is the difference between formatting and validating JSON?
Validation checks whether the JSON syntax is correct — that all brackets are balanced, keys are double-quoted, and values use proper types. Formatting (pretty printing) takes valid JSON and adds indentation and line breaks for readability. This tool performs both: it validates on paste and formats on click. Invalid JSON cannot be formatted until the syntax errors are fixed.
How do I format JSON in JavaScript?
Use `JSON.stringify(data, null, 2)` where the third argument controls the number of indentation spaces. For example: `const formatted = JSON.stringify({name: "Jane", age: 30}, null, 2)` produces a string with 2-space indentation. To minify, omit the third argument: `JSON.stringify(data)`. This is the same method this online tool uses internally.
How do I format JSON in Python?
Use `json.dumps(data, indent=4, sort_keys=True)` from Python's built-in `json` module. The `indent` parameter sets the number of spaces, and `sort_keys=True` alphabetizes keys. From the command line, run `python3 -m json.tool input.json` to format a file without writing a script.
How do I read deeply nested JSON?
Paste the nested JSON into the editor and click `Format`. The tool indents each level by 2 spaces, making parent-child relationships visible through alignment. After formatting, check the stats panel — the `Depth` value tells you how many levels deep the nesting goes. For example, `{"user": {"address": {"city": "NYC"}}}` has a depth of 3.
What is the difference between JSON and YAML?
JSON uses braces, brackets, and double quotes for structure, making it unambiguous for machines but verbose for humans. YAML uses indentation instead of braces and supports comments, making it popular for configuration files like Docker Compose and Kubernetes manifests. JSON is the standard for API payloads and data exchange, while YAML is preferred for human-edited config files. Both can represent the same data structures.
How do I format a JSON array?
JSON arrays use square brackets and can contain any mix of values: `[1, "hello", true, null, {"key": "value"}, [1, 2, 3]]`. Paste your array into the editor and click `Format` — each element gets its own line with proper indentation, making it easy to scan large datasets. Arrays of objects (common in API responses) are formatted with each object's opening brace on a new line.
Are there keyboard shortcuts?
Yes. Press `Ctrl+Enter` (or `Cmd+Enter` on Mac) to format the current input, `Ctrl+F` to search within the editor, and `Ctrl+L` to clear the input. These shortcuts work in both the input and output panels.