Copied!
Formatter

JSON Formatter & Validator

Paste any JSON to instantly pretty print, minify, or validate it with this free online JSON formatter. Syntax errors are detected and displayed with exact line and column numbers so you can fix issues fast. Features include customizable indentation (2 spaces, 4 spaces, or tabs), alphabetical key sorting, full syntax highlighting with color-coded tokens, and real-time JSON statistics showing size, key count, array count, and nesting depth. All formatting happens entirely in your browser — no data is sent to any server. Works offline, no signup required.

json-formatter.tool
0 characters
Output will appear here...

Frequently Asked Questions

What is JSON?
JSON (JavaScript Object Notation) is a lightweight, human-readable text format for storing and transmitting data. It consists of key-value pairs in objects {"key": "value"} and ordered arrays [1, 2, 3]. JSON supports six data types: string, number, boolean, null, object, and array. It's the dominant data format for REST APIs, configuration files, and database storage.
What are the most common JSON errors?
The top JSON errors are:
1. Single quotes — JSON requires double quotes around keys and strings. 'name'"name"
2. Trailing commas{"a": 1,} is invalid. Remove the comma after the last item.
3. Unquoted keys{name: "John"} is JavaScript, not JSON. Keys must be quoted.
4. Comments — JSON does not support // or /* */.
5. Undefined/NaN/Infinity — these JavaScript values are not valid JSON.
What is the difference between JSON pretty print and minify?
Pretty print adds indentation and line breaks, making JSON readable for humans. Use it for debugging, config files, and documentation. Minify removes all whitespace and newlines, reducing file size for network transmission. Minified JSON can be 20–30% smaller. Both produce equivalent data — only formatting differs.
Does JSON support comments?
No. Standard JSON (RFC 8259) does not support comments. This is intentional — JSON was designed as a data format, not a configuration format. If you need comments in config files, consider JSONC (JSON with Comments, used by VS Code), YAML, or TOML instead.
How do I parse JSON in JavaScript, Python, and Go?
JavaScript: const obj = JSON.parse(jsonString); — and serialize with JSON.stringify(obj, null, 2)
Python: import json; obj = json.loads(json_string) — serialize: json.dumps(obj, indent=2)
Go: import "encoding/json"; json.Unmarshal([]byte(jsonString), &obj)
PHP: $obj = json_decode($jsonString, true);
Is my JSON data safe to paste here?
Yes. All processing is done entirely in your browser using JavaScript's built-in JSON.parse() and JSON.stringify() APIs. No data is ever sent to a server. The tool works fully offline. We strongly recommend not pasting production secrets or API keys into any online tool — as a general security practice.