JSON Formatter

Format, validate, and minify JSON entirely in your browser.

Input
Output
{
  "sub": "1234567890",
  "name": "Jane Doe",
  "roles": [
    "admin",
    "user"
  ],
  "iat": 1700000000
}

What is a JSON formatter?

A JSON formatter (or "beautifier") takes compact or poorly-indented JSON and re-prints it with consistent indentation so nested objects and arrays are easy to scan visually. It also acts as a validator: if the input isn't syntactically valid JSON, parsing fails immediately with a descriptive error.

How it works

This tool calls the browser's native JSON.parse() to validate and parse your input, then JSON.stringify() with your chosen indentation to re-render it. Enable "Minify" to strip all whitespace and produce the smallest possible representation — useful for reducing payload size before sending over the wire.

Worked example

Paste a compact JWT payload like {"sub":"123","name":"Jane"} and the formatter expands it to multiple readable lines with 2-space indentation, making it far easier to review claims during debugging.

Common mistakes

  • Using single quotes instead of double quotes around strings and keys — invalid in strict JSON.
  • Leaving a trailing comma after the last property or array item.
  • Forgetting to quote object keys (valid in JavaScript object literals, invalid in JSON).
  • Confusing JSON with JavaScript — functions, comments, and undefined aren't valid JSON values.

Security notes

Parsing happens entirely client-side with no network calls, so it's safe to paste sensitive configuration or token payloads here for inspection — just avoid pasting production secrets into any tool you don't fully trust.

Code examples

JavaScript
const pretty = JSON.stringify(JSON.parse(raw), null, 2);
Python
import json
print(json.dumps(json.loads(raw), indent=2))

JSON Formatter FAQ

What does a JSON formatter do?

It parses JSON text and re-prints it with consistent indentation and line breaks, making nested objects and arrays easy to read. It also validates syntax and reports the exact error location if the JSON is malformed.

Can I minify JSON with this tool?

Yes — switch to the 'Minify' mode to collapse formatted JSON into the smallest possible single-line representation, useful for reducing payload size.

Why does my JSON fail to parse?

Common causes are trailing commas, single quotes instead of double quotes, unquoted keys, or missing commas between properties — all invalid in strict JSON.

Is my data uploaded when I format it?

No — parsing and formatting happen entirely in your browser using JSON.parse and JSON.stringify. Nothing is sent to a server.

Can I format a JWT payload here?

Yes — decode a JWT segment with the Base64 Decoder or JWT Decoder first, then paste the resulting JSON here for pretty-printing.

What indentation does the formatter use?

You can choose 2-space, 4-space, or tab indentation from the options below.

Related tools