PrettyJSON Logo
PrettyJSON

Instantly clean, validate, and inspect web payloads

Sample Payloads
Buy me a coffee
Raw JSON Input

Waiting for JSON content

Start typing on the left or load one of the sample payloads to inspect it instantly.

RFC 8259 Compliant & 100% Client-Side

JSON Formatter Online — Pretty Print & Format JSON

Instantly format JSON and pretty print JSON online with clean 2-space or 4-space indentation. RFC 8259 compliant, 100% in-browser processing, zero server upload.

Private & Offline Ready

Every tool runs in your browser, so the JSON you paste never leaves your device.

Works Instantly, Even Offline

Formatting, minifying, repairing, and the tree view all run on your device, so there are no uploads to wait on.

Exact Error Line & Column

Syntax errors like unescaped quotes and trailing commas are flagged with their exact line and column.

How JSON Formatting Works: Indentation and the RFC 8259 Standard

How pretty-printing adds indentation, what the JSON standard requires, and how special characters are preserved.

1. 2-Space vs 4-Space Indentation

Pretty-printing JSON means walking the parsed object and array tree and adding a line break plus a set number of spaces at each level of nesting. The indent width is your choice. 2-space indentation is the common default for JSON in the JavaScript and TypeScript world — package.json, tsconfig.json, and most API documentation use it, and it keeps deeply nested objects from drifting too far to the right. 4-space indentation is more common in Python and Java projects, where the wider indent is a little easier to scan. PrettyJSON switches between the two instantly and re-serializes the same parsed data, so formatting your JSON never changes the underlying values.

Technical Highlights

  • 2-space indentation is the common default for JSON in JavaScript and TypeScript projects.
  • 4-space indentation is typical in Python and Java codebases.
  • Changing the indent width reformats the same data — it never alters your values.

2. What Valid JSON Requires (RFC 8259)

RFC 8259 is the specification that defines JSON. Two rules matter most when you format: every key and every string value must use double quotes — single quotes, backticks, and unquoted keys are all invalid — and JSON allows only six value types: string, number, object, array, boolean (true or false), and null. PrettyJSON parses your input against these rules before it formats, so if the output comes back neatly indented, you also know the JSON is valid. If it cannot be parsed, you get a clear error instead of silently broken output.

A Valid, Formatted JSON Example
{
  "api_version": "v2.4",
  "status": "success",
  "http_code": 200,
  "payload": {
    "user_id": 89412,
    "is_active": true,
    "metadata": null
  }
}
Explanation: Keys and string values use double quotes, numbers are unquoted, and booleans and null are lower-case — the format PrettyJSON produces.

3. Unicode and Special Characters

JSON is UTF-8 text, and characters can appear either directly or as escape sequences — PrettyJSON preserves both. Escaped control characters such as newline, tab, carriage return, and escaped quotes are kept intact, and multi-byte characters like emoji are handled without being split or corrupted. In other words, formatting changes the spacing around your data, never the text inside it.

Technical Highlights

  • Both literal UTF-8 characters and escape sequences are preserved.
  • Escaped control characters such as newline, tab, and quotes are kept intact.
  • Multi-byte characters like emoji are never split or corrupted.

Frequently Asked Questions

Common questions and expert answers regarding this tool.

What is a JSON Formatter and Beautifier?

A JSON formatter takes messy or minified JSON and adds line breaks and indentation (2 or 4 spaces) so the structure is easy to read. "Beautifier" is just another name for the same thing. PrettyJSON does it in your browser, so the JSON you paste is never uploaded to a server.

Should I use 2-space or 4-space indentation?

It is mostly convention. 2-space indentation is the common default for JSON in JavaScript and TypeScript projects and keeps nested objects compact; 4-space is typical in Python and Java and is a little easier to scan. Pick whichever matches your codebase — the formatted data is identical either way.

Does formatting JSON change my data or key order?

No. Formatting only changes whitespace. Numbers stay numbers, strings stay strings, and keys keep their original order. If you want keys sorted alphabetically instead, use the JSON Sorter.