JSON Formatter: How to Format, Validate and Minify JSON Online
Table of contents
JSON is the standard format for API responses and configuration files, and it is almost always delivered as a single unbroken line, because whitespace costs bandwidth and machines do not need it. Formatting adds indentation and line breaks so a human can actually read the structure; validating confirms the syntax is legal before you waste time debugging the wrong thing. The format itself is deliberately small: an object in curly braces with double-quoted keys, an array in square brackets, and six value types - string, number, boolean, null, object and array. That strictness is what makes JSON portable, and also what trips people up, because the rules are narrower than they look. Trailing commas are invalid. Keys must use double quotes, never single. Comments are not allowed at all. This tool formats, validates and minifies entirely in your browser, so API keys and customer records inside a payload never leave your machine.
Key benefits
- Turns an unreadable single-line payload into something you can actually navigate.
- Validates syntax immediately, so you find the missing comma instead of guessing why an API call fails.
- Minifies as well as formats, so the same tool covers both debugging and shipping.
- Runs entirely in your browser - API keys, tokens and personal data in a payload are never transmitted.
- Handles large payloads without a size limit imposed by a server.
How to use it, step by step
- Paste your JSON. Drop in the raw response or file contents. It does not matter whether it is minified or already indented.
- Format it. The structure is re-indented so nesting is visible at a glance, and the collapsible tree view lets you fold sections you are not interested in.
- Read any error reported. If the syntax is invalid, the position of the problem is shown. That is normally within a character or two of the real mistake.
- Copy or minify. Take the formatted version for reading and debugging, or minify back to one line for production use where size matters.
Common use cases
- Reading an API response while debugging an integration.
- Checking a package.json, tsconfig.json or CI configuration file before committing it.
- Validating a payload before sending it, to rule out syntax as the cause of a 400 error.
- Inspecting a webhook body that arrived as one long line in a log.
- Minifying a configuration file to reduce bundle size.
Pro tips
- Read the reported error position first. JSON parsers report where parsing became impossible, which is usually just after the actual mistake.
- A missing or extra comma is by far the most common error. Check the line above the one reported, not just the one named.
- If your JSON comes from JavaScript, keys may be unquoted or single-quoted - both are valid JavaScript and invalid JSON.
- For files that need comments, you probably want JSON5 or YAML. Standard JSON has no comment syntax and never will.
- Use the tree view for deeply nested data. Counting brackets by eye is what causes the mistakes in the first place.
Common mistakes to avoid
- Leaving a trailing comma after the last item. Legal in JavaScript, illegal in JSON, and the single most common cause of parse failures.
- Using single quotes around keys or strings. JSON requires double quotes for both.
- Adding // or /* */ comments. JSON has no comment syntax, so any comment makes the whole document invalid.
- Writing NaN, Infinity or undefined as values. None of them exist in JSON - use null or a string.
- Wrapping numbers in quotes by accident, which turns 42 into the string "42" and breaks type checks downstream.
Frequently asked questions
How do I format JSON?
Paste your JSON above and it is indented and validated immediately. Nesting becomes visible, the tree view lets you collapse sections, and any syntax error is reported with its position.
Is this JSON formatter free?
Yes - no account, no size cap and no paid tier. Everything runs locally in your browser.
Is my JSON data sent anywhere?
No. Parsing, formatting and validation all happen in your browser using its own JSON engine. This matters because API payloads routinely contain tokens, keys and personal data - none of it is transmitted.
What happens if my JSON has a syntax error?
It is flagged as invalid with the position where parsing failed. Note that the real mistake is often slightly before that point - a missing comma at the end of one line is reported when the parser reaches the next.
What is the difference between formatting and minifying?
Formatting adds indentation and line breaks for humans. Minifying strips every unnecessary character to make the payload as small as possible for transmission. The data is identical either way - only the whitespace differs.
Why is my JSON invalid when it looks fine?
The usual culprits are a trailing comma after the last element, single quotes instead of double, an unquoted key, or a comment. All four are valid JavaScript and none are valid JSON.
People also search for
- json formatter online free
- json validator
- json beautifier
- json pretty print
- json minifier
- format json vscode
- why is my json invalid
- json viewer tree
Ready to get started? Open the JSON Formatter and try it now - completely free.