How to Format JSON
Several good ways to pretty-print JSON, depending on where you’re working.
Online (Fastest)
Paste into ParseJSON Formatter and click Format. Done.
JavaScript / Node.js
const data = JSON.parse(minifiedString);
const formatted = JSON.stringify(data, null, 2); // 2-space indent
console.log(formatted);The third argument to JSON.stringify controls indentation. Use a number for spaces, or a string (like '\\t') for tabs.
Python
import json
with open('data.json') as f:
data = json.load(f)
print(json.dumps(data, indent=2))Command Line – Python
# From a file:
python -m json.tool data.json
# From curl output:
curl https://api.example.com/data | python -m json.toolCommand Line – jq
# Install: brew install jq (macOS) or apt install jq (Debian/Ubuntu)
cat data.json | jq .
# From curl:
curl https://api.example.com/data | jq .jq is the most powerful option — it can filter, transform, and format JSON from the command line.
Browser DevTools
In Chrome, Firefox, or Edge:
- Open DevTools (F12 or Cmd+Option+I)
- Go to the Network tab
- Click any request with a JSON response
- Click the Preview or Response tab
- Most DevTools automatically pretty-print JSON responses