About the JSON Formatter tool
API responses, log lines and config exports often arrive as one long line of JSON that is almost impossible to read. This JSON formatter takes that wall of text and rewrites it with two-space indentation, one key per line and properly nested brackets, so you can see the structure of the data at a glance and spot the field you are looking for.
The same tool works in the other direction too. Minify strips every unnecessary space and line break, which is handy when you need to paste JSON into an environment variable, a single-line config value or a test fixture. Both actions first run your text through the browser’s own strict JSON parser, so if something is wrong, such as a trailing comma, single quotes or a missing bracket, you are told the JSON is invalid instead of getting a half-formatted result.
Everything runs locally in your browser with plain JavaScript. Your data is not uploaded, logged or stored anywhere, which makes it safe to format tokens, customer records or internal API payloads while you debug.
How to use JSON Formatter
- Paste your JSON into the “Input JSON” box.
- Click “Format / Beautify” to indent it with two spaces per level.
- Or click “Minify” to squeeze it into a single compact line.
- If you see “Invalid JSON format” under the buttons, correct the input (look for trailing commas, single quotes or missing brackets) and click again.
- Click “Copy” above the output to put the result on your clipboard.
Features
Beautify with clean indentation
Nested objects and arrays are laid out with consistent two-space indentation for easy reading.
One-click minify
Remove all whitespace to get the smallest valid JSON string for configs and requests.
Strict validation
Input is checked with the browser’s standard JSON parser, and an “Invalid JSON format” message appears if it fails.
Copy to clipboard
Grab the formatted or minified result with a single click.
Private and offline-friendly
Formatting happens in your browser tab; nothing is sent to a server.
When to use it
- Read a minified REST or GraphQL response copied from the browser’s network tab.
- Tidy a package.json, tsconfig or composer file before committing it.
- Check whether a webhook payload is valid JSON before sending it to a partner.
- Minify a JSON object so it fits into a single environment variable or CLI argument.
- Make sample data readable for documentation, tickets and code reviews.
Frequently asked questions
Why does it say my JSON is invalid?
Strict JSON does not allow trailing commas, single-quoted strings, comments or unquoted keys. Remove those and make sure every bracket and brace is closed, then format again.
What indentation does the formatter use?
Formatted output always uses two spaces per nesting level, which is the most common style in JavaScript and web projects.
Does formatting change my data?
Values are kept and normally only whitespace changes. Because the JSON is parsed by JavaScript, duplicate keys keep only the last value, number-like keys move to the front, and numbers beyond the safe integer range may lose precision.
Is my JSON uploaded anywhere?
No. Parsing and formatting happen entirely in your browser, so you can safely paste private or production data.
Can I convert JSON to CSV, YAML or XML?
Yes. Use the JSON to CSV, JSON to YAML or JSON to XML converters on this site, which accept the same input and add download buttons.
Can I format JSON that contains comments?
No. Comments are not part of the JSON standard, so the parser rejects them. Remove // and /* */ comments first, or keep the file as JSONC in your editor.