JSON is the format most web APIs, config files and apps use to exchange data. But JSON returned by an API is often squeezed onto one long line, and a single missing comma breaks the whole file.
This guide shows how to format, validate and minify JSON for free.
How to format JSON step by step
- Open the JSON Formatter.
- Paste your JSON into the top box.
- Choose the indentation: 2 spaces, 4 spaces or tabs.
- Click Format. The readable version appears below, and you see "Valid JSON" if there are no errors.
- Click Copy result to copy it.
How to minify JSON
Minifying removes every unnecessary space and line break, making the file as small as possible for APIs and production apps. Paste your JSON and click Minify.
Common JSON errors and how to fix them
- Trailing comma:
{"a": 1,}is invalid. Remove the last comma. - Single quotes: JSON needs double quotes.
{'a': 1}must be{"a": 1}. - Unquoted keys:
{a: 1}must be{"a": 1}. - Comments: standard JSON does not allow
//comments. - Missing brackets: every
{and[needs a matching close.
When the JSON is invalid, the formatter shows the error message from your browser, which usually points to the position of the problem.
Is it safe to paste API data?
Yes. Formatting and validation happen in your browser. Your JSON is not sent to any server, so you can safely work with API responses and configuration that contain private data.
Related developer tools
Need to encode data for a URL or an email attachment? Try Base64 Encode / Decode.
Frequently asked questions
How do I check if my JSON is valid?
Paste it and click Format. You will see "Valid JSON" or an error message describing the problem.
What is the difference between formatting and minifying?
Formatting adds indentation so humans can read it. Minifying removes spaces so the file is as small as possible.
Can JSON have comments?
No. Standard JSON does not support comments, so remove them before validating.
Is my data uploaded?
No. The JSON is processed locally in your browser.