How to Format and Validate JSON
Whether you're debugging an API response, editing a config file, or inspecting data from a database, readable JSON makes everything easier. This guide shows you how to format, minify, and validate JSON instantly in your browser.
When You Need a JSON Formatter
- An API returns a single long line of JSON and you need to read it
- You want to validate JSON before sending it in a request body
- A config file has a syntax error and you need to find it
- You need to minify JSON to reduce payload size
- You want to copy nicely indented JSON into documentation
How to Format (Pretty-Print) JSON
Step 1: Open the tool
Go to the JSON Formatter & Validator.
Step 2: Paste your JSON
Paste your JSON into the input editor on the left. The editor shows line numbers to help you navigate large documents.
Step 3: Click Format
Click the "Format" button. Your JSON appears in the output panel with proper indentation (2 spaces by default). You can switch between 2-space and 4-space indentation using the indent toggle.
Step 4: Copy or download
Click "Copy" to copy the formatted JSON to your clipboard, or "Download" to save it as a .json file.
How to Minify JSON
Step 1: Paste your JSON
Paste the JSON you want to compress into the input editor.
Step 2: Click Minify
Click the "Minify" button. All unnecessary whitespace is removed, producing the most compact representation. This is useful when you need to reduce the size of JSON payloads or config files.
How to Validate JSON
Validation happens automatically as you type or paste. If your JSON has a syntax error, the tool highlights the error with a clear message showing the line number and what went wrong — for example, "Unexpected token at line 5".
Common JSON syntax errors include:
- Trailing commas — JSON does not allow a comma after the last item in an array or object
- Single quotes — JSON requires double quotes for strings and keys
- Unquoted keys — unlike JavaScript objects, JSON keys must be quoted
- Missing brackets — an unclosed
{or[
Tips
- Use 2-space indentation for compact output (common in web development) or 4-space for maximum readability (common in Python projects).
- If you're working with JSON from an API, try formatting first to understand the structure, then use the JSON to CSV converter if you need tabular data.
- For large JSON files, the line numbers in the editor help you communicate specific locations to teammates ("check line 42").
FAQ
What does JSON formatting do?
JSON formatting (also called pretty-printing) adds indentation and line breaks to make JSON human-readable. It doesn't change the data — only the whitespace.
What is JSON minification?
Minification removes all unnecessary whitespace from JSON, producing the smallest possible string. This is useful for reducing payload size in APIs and config files.
How do I fix invalid JSON?
Common issues include trailing commas, single quotes instead of double quotes, unquoted keys, and missing brackets. Our tool highlights the exact line and position of syntax errors so you can fix them quickly.
Is my data sent to a server?
No. All formatting, minification, and validation happens entirely in your browser using JavaScript. Your data never leaves your device.
Try It Now
Ready to clean up your JSON? Open the JSON Formatter & Validator — it works entirely in your browser with no sign-up required.