JSON Formatter
Beautify, minify and validate JSON instantly. Syntax highlighting included.
Output will appear here...What is JSON?
JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging structured data. It is the standard format used by virtually every modern web API, from REST endpoints to GraphQL responses. JSON consists of key-value pairs, arrays, and nested objects, making it human-readable and easy for machines to parse. Despite its simplicity, minified or deeply nested JSON can be extremely difficult to read without a formatter.
What Does the JSON Formatter Do?
The formatter takes raw or minified JSON and outputs a cleanly indented, syntax-highlighted version that is easy to read and navigate. It also validates the JSON in real time — if your input contains a syntax error such as a missing comma, unclosed bracket, or illegal character, the tool shows a precise error message pointing to the problem. You can also minify JSON to remove whitespace and reduce payload size before sending data over a network.
Common Use Cases
- API debugging — Paste an API response to immediately see its structure, check field names, and validate types.
- Config file inspection — Format package.json, tsconfig.json, or any other configuration file for readability.
- Data validation — Verify that a JSON payload is valid before sending it to an endpoint or storing it in a database.
- Log analysis — Many logging systems output JSON logs on a single line; paste them here to expand and inspect.
- Minification — Compress a formatted JSON file to reduce bytes sent over the wire in API requests or localStorage.
How to Format JSON Online
- Copy the raw or minified JSON you want to read — an API response, a log line, or a config file.
- Paste it into the input box above. Formatting happens instantly as you type.
- Read the indented, syntax-highlighted output. If the JSON is invalid, an error message points to the exact problem.
- Click copy to grab the beautified result, or switch to minify to compress it back down.
2-Space vs 4-Space Indentation
Both are valid — the choice is purely about readability and team convention. Two-space indentation keeps deeply nested JSON compact and is the default in most JavaScript and Node.js projects (it matches Prettier's default). Four-space indentation is easier to scan for some readers and is common in Python-adjacent tooling. Because indentation only affects whitespace, you can reformat between the two at any time without changing the data.
How to Fix Common JSON Syntax Errors
- Unexpected token — usually a trailing comma after the last item in an object or array, or a missing comma between items. JSON does not allow trailing commas.
- Unexpected end of JSON input — an unclosed
{,[, or string quote. Check that every bracket and quote is closed. - Unquoted keys — every key must be wrapped in double quotes.
{ name: "x" }is invalid;{ "name": "x" }is correct. - Single quotes — JSON requires double quotes for both keys and string values. Single quotes are a common copy-paste mistake from JavaScript.
- Comments — standard JSON does not support
//or/* */comments. Remove them before parsing.
Frequently Asked Questions
Does my JSON get sent to a server?
No. All formatting, validation, and minification happens locally in your browser using JavaScript. Your JSON data never leaves your device and is never stored anywhere. This makes it safe to use with sensitive API keys, personal data, or internal config files.
What JSON syntax errors can it detect?
The validator uses the browser's native JSON.parse engine, which catches all standard JSON syntax errors including: trailing commas, missing quotes around keys, mismatched brackets, unescaped special characters, and invalid number formats. The error message includes the position in the text where the problem was found.
What is the difference between beautify and minify?
Beautify (also called prettify or format) adds indentation and line breaks to make the JSON easy for humans to read. Minify removes all whitespace to produce the smallest possible string, which is useful for reducing the size of API payloads or files sent over a network.
Is JSON the same as a JavaScript object?
They look similar but are not the same. JSON is a text format with strict rules: keys must be double-quoted strings, trailing commas are not allowed, and special values like undefined or functions are not supported. A JavaScript object is a runtime value that can be converted to JSON with JSON.stringify() and back with JSON.parse().
How do I format JSON with 4-space indentation?
Paste your JSON and choose the 4-space indent option. The formatter re-indents the entire document using four spaces per nesting level. You can switch back to 2-space at any time — indentation is cosmetic and never alters the underlying data.
Can I format a very large JSON file?
Yes. Because formatting runs locally in your browser rather than on a server, there is no upload limit or request timeout. Very large files (tens of megabytes) depend on your device's available memory, but there is no artificial cap imposed by the tool.
Why does my JSON say "Unexpected token"?
That error almost always means a trailing comma, a missing comma between items, or single quotes where JSON requires double quotes. The error message shows the position of the problem so you can jump straight to it. See the section above on fixing common JSON errors.