ParseJSON LogoParseJSON

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.tool

Command 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:

  1. Open DevTools (F12 or Cmd+Option+I)
  2. Go to the Network tab
  3. Click any request with a JSON response
  4. Click the Preview or Response tab
  5. Most DevTools automatically pretty-print JSON responses

Related Tools