How to Format and Validate JSON Online (Pretty Print)

2 min read
Beginner JSON Format Validate Developer

You got a blob of JSON from an API response, a config file, or a log output. It looks like this:

{"name":"Sam","servers":[{"host":"10.0.0.35","port":443,"ssl":true},{"host":"10.0.0.36","port":8080,"ssl":false}],"updated":"2026-04-03"}

Unreadable. You need it formatted so you can actually work with it. Or you wrote some JSON and need to check if it is valid before using it.

Format JSON Now

Use our free JSON Formatter:

  1. Paste your messy JSON
  2. Click Format — instantly pretty-printed with proper indentation
  3. Click Minify to compress it back for production use
  4. Errors are highlighted if the JSON is invalid

What "Pretty Print" Looks Like

Before:

{"name":"Sam","servers":[{"host":"10.0.0.35","port":443,"ssl":true},{"host":"10.0.0.36","port":8080,"ssl":false}],"updated":"2026-04-03"}

After formatting:

{
  "name": "Sam",
  "servers": [
    {
      "host": "10.0.0.35",
      "port": 443,
      "ssl": true
    },
    {
      "host": "10.0.0.36",
      "port": 8080,
      "ssl": false
    }
  ],
  "updated": "2026-04-03"
}

Same data, now you can actually read it.

Common JSON Errors

Our formatter highlights exactly where the error is. Here are the most common mistakes:

Trailing Comma

{
  "name": "Sam",
  "age": 30,
}

The comma after 30 is invalid. JSON does not allow trailing commas.

Single Quotes

{'name': 'Sam'}

JSON requires double quotes. Single quotes are not valid.

Missing Quotes on Keys

{name: "Sam"}

Keys must be in double quotes: "name".

Unescaped Special Characters

{"path": "C:\Users\Sam"}

Backslashes must be escaped: "C:\\Users\\Sam".

When You Need JSON Formatting

Situation What to Do
API response Paste into formatter to read the data structure
Config file editing Format to edit, minify before saving
Debugging Format to find where data is wrong
Documentation Format for readable examples
Sending in Slack/email Format so others can read it
Log analysis Format log entries for readability

Format JSON in Your Terminal

# Using jq (install: apt install jq / brew install jq)
echo '{"name":"Sam"}' | jq .

# Using Python
echo '{"name":"Sam"}' | python3 -m json.tool

# Using Node.js
echo '{"name":"Sam"}' | node -e "process.stdin.resume();process.stdin.on('data',d=>console.log(JSON.stringify(JSON.parse(d),null,2)))"

Related Tools