JSON Formatter
Pretty Print & Minify
Pretty-print or minify JSON with live validation and adjustable indent (1–8 spaces). Line-level errors stay visible—free online, no signup, browser-only.
This conversion runs only in your browser — nothing is uploaded.
- Input0
- Output0
- OptionsPrettify · 2 spaces
Input
Output
What is this tool?
This JSON formatter validates, pretty-prints, and minifies strict JSON with the browser’s JSON.parse / JSON.stringify. Double-quoted keys and strings are required; comments, trailing commas, and single quotes are rejected.
Pretty-print adds line breaks and 1–8 spaces of indentation so nested objects and arrays are readable in reviews, logs, and fixtures. Minify removes insignificant whitespace for compact transport or embedding.
Use it to inspect API responses, clean config snippets, prepare examples, or confirm a pasted payload is valid before handing it to another system. YAML ↔ JSON conversion is a separate tool.
Common use cases
- Debug a compact or one-line API response by expanding it with readable indent
- Strip whitespace before embedding JSON in a query string, log line, or code sample
- Catch trailing commas and quote mistakes before a deploy or schema check
How to use
- Choose Prettify or Minify. Output updates live as you type.
- For Prettify, pick indent 1–8 spaces; changes apply immediately.
- Paste JSON into the input. Errors show a line and message above the editors.
- Copy when the Valid badge appears. Fix Invalid JSON before relying on the output.
Examples
| Input / setting | Output | Notes |
|---|---|---|
{"id":1,"name":"Ada"} → Prettify (2) | Multi-line object with two-space indent | Classic pretty-print. |
| Multi-line object → Minify | {"id":1,"name":"Ada"} | Whitespace removed. |
{id:1} | Parse error (unquoted key) | Strict JSON requires "id". |
{"a":1,} | Parse error (trailing comma) | Common API / JS-object copy-paste mistake. |
Practical pitfalls
- Trailing commas and single quotes look fine in JavaScript object literals but fail strict JSON—convert quotes and drop the last comma.
- Large payloads can slow or freeze a tab; stay within browser memory limits.
- This page does not convert YAML, JSON5, or JSONC. Use the YAML ↔ JSON tool for YAML round-trips.
References
Last reviewed: 2026-07-26
Frequently asked questions
- Does this support JSON5 or comments?
- No. It uses strict `JSON.parse`, so comments (`//`, `/* */`), trailing commas, single-quoted strings, and unquoted keys are invalid.
- Can I choose indentation when pretty-printing?
- Yes. Set indent from 1 to 8 spaces; the output updates live. Minify ignores indent and removes whitespace.
- Why does my API response fail to parse?
- Common causes are trailing commas after the last property, single quotes instead of double quotes, or a truncated body. Fix the highlighted line, then copy the formatted result.
- Is my JSON uploaded?
- No. Formatting and validation run only in your browser.