{}JSON FYI
JSON Pretty Print

JSON Pretty Print — Free Online Beautifier

Paste JSON and get a pretty-printed, indented version instantly. Matches JSON.stringify(obj, null, 2) in JavaScript and json.dumps(indent=2) in Python.

Ready when you are.

Paste JSON on the left, or click Sample to try a quick example. Validation runs as you type — entirely in your browser.

EmptyType: Nodes: 0Depth: 0Size: 0 B

What does "pretty print" mean?

Pretty printing is the universal term for taking a compact JSON document — usually one long line — and adding indentation, line breaks, and consistent spacing so a human can read it. The data is unchanged; only whitespace is added.

Almost every language ships with a pretty-printer built in:

  • JavaScript: JSON.stringify(obj, null, 2)
  • Python: json.dumps(obj, indent=2)
  • Ruby: JSON.pretty_generate(obj)
  • Go: json.MarshalIndent(obj, "", " ")
  • Command line: jq . or python3 -m json.tool

This tool gives you the same result without writing any code — paste, click, copy.

Examples

JavaScript-style 2-space indent
Input
{"id":1,"name":"Ada"}
Output
{
  "id": 1,
  "name": "Ada"
}

Equivalent to JSON.stringify(obj, null, 2).

Python-style 4-space indent
Input
{"items":[1,2,3],"total":6}
Output
{
    "items": [
        1,
        2,
        3
    ],
    "total": 6
}

Equivalent to json.dumps(obj, indent=4).

Sorted keys (canonical form)
Input
{"z":1,"a":2,"m":3}
Output
{
  "a": 2,
  "m": 3,
  "z": 1
}

Equivalent to json.dumps(obj, indent=2, sort_keys=True).

Tabs (Go-style)
Input
{"name":"Ada","tags":["a","b"]}
Output
{
	"name": "Ada",
	"tags": ["a", "b"]
}
Deeply nested
Input
{"a":{"b":{"c":{"d":"deep"}}}}
Output
{
  "a": {
    "b": {
      "c": {
        "d": "deep"
      }
    }
  }
}

Use cases

Frequently asked questions

What is JSON pretty print?+

Pretty print is the term for formatting JSON with indentation and line breaks so a human can read it. It's what JSON.stringify(obj, null, 2) does in JavaScript and json.dumps(obj, indent=2) in Python.

How do I pretty print JSON in JavaScript?+

JSON.stringify(value, null, 2) returns a pretty-printed string with 2-space indent. Replace 2 with 4 for 4-space indent, or '\t' for tabs.

How do I pretty print JSON in Python?+

import json; print(json.dumps(data, indent=2)) prints it pretty. Add sort_keys=True to canonicalize.

How do I pretty print JSON from the command line?+

Use jq: cat file.json | jq . pretty-prints any JSON to stdout. Or python3 -m json.tool file.json works without installing anything.

Is online pretty printing safe?+

On JSON FYI, yes — your JSON is never sent to a server. Everything runs in your browser. Many other online tools do upload, so check before pasting sensitive data.

Pretty-print JSON in code

Stable, sorted-key output for diffs, fixtures, and snapshot tests.

Pretty-print with sorted keys

Stable, diff-friendly JSON for fixtures and snapshots — keys sorted alphabetically.

node pretty.js
import { readFileSync, writeFileSync } from "node:fs";

const sortKeys = (v) =>
  Array.isArray(v)
    ? v.map(sortKeys)
    : v && typeof v === "object"
      ? Object.fromEntries(Object.keys(v).sort().map(k => [k, sortKeys(v[k])]))
      : v;

const data = JSON.parse(readFileSync("input.json", "utf8"));
writeFileSync("output.json", JSON.stringify(sortKeys(data), null, 2));
Input
{"name":"Ada","age":36,"id":1}
Output
{
  "age": 36,
  "id": 1,
  "name": "Ada"
}

Other JSON tools on JSON FYI

Every flow you need — formatter, validator, viewer, pretty print, repair, and the full workbench.

Related tools & guides