JSON Pretty Print

Format and beautify minified JSON. Paste your JSON below:

141 chars
Loading...
0 chars
Loading...

What is Pretty Printing?

Pretty printing (also called beautifying) adds whitespace, indentation, and line breaks to JSON to make it human-readable. Minified JSON saves bandwidth but is nearly impossible to read. Pretty printing solves this.

Before (minified)

{"name":"John","age":30,"address":{"city":"New York","zip":"10001"}}

After (pretty printed)

{
  "name": "John",
  "age": 30,
  "address": {
    "city": "New York",
    "zip": "10001"
  }
}

How to Use

  1. Paste your JSON — Minified or already formatted
  2. Choose indentation — 2 spaces (common), 4 spaces, or 1 space
  3. Optional: Sort keys — Alphabetize object keys
  4. Copy or download — Use the formatted result

The tool formats automatically as you type. You can also click "Format JSON" to manually trigger formatting.

Formatting Options

Indentation

  • 2 spaces — Most common, used by JavaScript/TypeScript projects
  • 4 spaces — Common in Java, Python, and some style guides
  • 1 space — Compact but readable

The JSON specification doesn't mandate any particular indentation. Choose what matches your project's style guide or personal preference.

Sort Keys

Enable "Sort keys alphabetically" to reorder object keys A-Z. This helps with:

  • Comparing two JSON files (consistent ordering)
  • Finding specific keys quickly
  • Cleaner version control diffs

For more sorting options, try our dedicated JSON Sorter.

Pretty Print in Code

Most JSON libraries support pretty printing. Here's how to do it programmatically:

JavaScript

// Format with 2-space indentation
const formatted = JSON.stringify(obj, null, 2);

// The third argument is the indent:
// - number: spaces (2, 4, etc.)
// - string: literal indent ("\t" for tabs)

Python

import json

# Format with 2-space indentation
formatted = json.dumps(obj, indent=2)

# With sorted keys
formatted = json.dumps(obj, indent=2, sort_keys=True)

Command Line (jq)

# Pretty print a file
cat data.json | jq '.'

# Pretty print with sorted keys
cat data.json | jq -S '.'

Why Pretty Print JSON?

  • Debugging — Quickly understand API responses and data structures
  • Documentation — Create readable examples for docs and tutorials
  • Code review — Make JSON changes easier to review
  • Learning — Understand nested structures visually
  • Configuration — Keep config files readable

Pretty Print vs Minify

These are opposite operations:

Pretty PrintMinify
Adds whitespaceRemoves whitespace
Human-readableMachine-optimized
Larger file sizeSmaller file size
For development/debuggingFor production/transfer

Need to compress JSON instead? Use our JSON Minify tool.

Related Tools

Frequently Asked Questions

What's the difference between pretty print and beautify?

Nothing — they're the same thing. "Pretty print," "beautify," and "format" all refer to adding indentation and line breaks to make JSON readable.

Does pretty printing change the data?

No. Pretty printing only adds whitespace. The actual data (keys, values, structure) remains identical. The formatted JSON is semantically equivalent to the minified version.

What indentation should I use?

2 spaces is the most common convention, especially in JavaScript ecosystems. Use 4 spaces if your project style guide requires it. The choice is purely cosmetic — it doesn't affect the data.

Can I pretty print invalid JSON?

No. The JSON must be valid to be formatted. If you have invalid JSON, this tool will show an error message indicating what's wrong. Fix the syntax error first, then format.