JSON Formatter
API responses, log lines and config files often arrive as one long, unreadable line of JSON. The JSON Formatter turns that into neatly indented text where every object and array is easy to follow, and it can squeeze formatted JSON back onto one line when size matters.
It also tells you immediately when the text is not valid JSON. Everything runs in your browser using its built-in JSON parser, so data such as customer records or API keys is never uploaded.
Beautify versus minify
Beautifying adds line breaks and two-space indentation so that nested structures line up. {"a":1,"b":[1,2]} becomes an object with each key and array item on its own line, which makes it easy to spot a missing field or a wrong value while debugging.
Minifying does the opposite: it removes every space and line break JSON does not need. The data is identical, but the text is shorter, which helps when pasting into a request body or storing large payloads. Neither operation changes keys, values or their order.
Why JSON fails to validate
Most invalid JSON comes from a handful of mistakes, often because text was copied from JavaScript code:
- a trailing comma after the last item in an object or array
- single quotes instead of double quotes
- keys without quotes
- comments, which standard JSON does not allow
When the formatter cannot parse the text it shows an error instead of a result. Fix the problem and run it again. The tool follows the JSON standard strictly, so formats such as JSON5 that allow comments will be reported as invalid.
How to use this tool
- Paste your JSON: Paste an API response, config file or any JSON text into the input.
- Click Beautify or Minify: Beautify indents it for reading; Minify puts it on one line.
- Read any error: Invalid JSON produces an error message instead of a result.
- Copy or download: Copy the result or download it as a file.
Features
- Beautify with consistent two-space indentation
- Minify to a single line
- Clear error for invalid JSON
- Copy and download
- Runs in your browser; nothing is uploaded
Worked examples
Formatting a compact API response
An API returns {"a":1,"b":[1,2]} on a single line.
{
"a": 1,
"b": [
1,
2
]
}
Result: Each key and array item on its own line, indented by two spaces.
Who it is for
- Developers: Read API responses and debug config files quickly.
- QA testers: Check that test payloads are valid before sending them.
- Students: See the structure of JSON clearly while learning web development.
Tips
- Use double quotes for all keys and strings.
- Remove trailing commas and comments before validating.
- Minify only after you finish editing.
- Avoid pasting live secrets into tools that upload data; this one does not.
Frequently asked questions
Is my JSON uploaded anywhere?
No. The formatter uses your browser's built-in JSON parser, so the text you paste never leaves your device. That makes it safe for payloads containing personal data or keys.
Why does my JSON show as invalid?
Common causes are a trailing comma, single quotes, unquoted keys or comments, none of which standard JSON allows. Fix the reported problem and format again.
Does formatting change my data?
No. Beautifying and minifying only add or remove whitespace between values. Keys, values and their order stay exactly the same, so programs read both versions identically.
What is the difference between JSON and a JavaScript object?
JSON is a stricter text format: keys and strings must use double quotes, and functions, comments and trailing commas are not allowed. Code copied from JavaScript often needs these small fixes to become valid JSON.