How to use the JSON Formatter
- Paste your JSON into the Input JSON box, drop a
.jsonfile on it, or click Load sample. - The output updates as you type. Choose Beautify with 2 spaces, 4 spaces or tabs — or Minify to strip all whitespace.
- If the JSON is invalid, the error is shown with its line and column. Click Jump to error to select the exact character in the input.
- Switch to Tree to explore nested data; click any value to copy its path (e.g.
$.variants[0].color). - Click Copy or Download to save the result.
What is a JSON formatter?
A JSON formatter (also called a JSON beautifier or pretty-printer) takes compact or messy JSON and rewrites it with consistent indentation and line breaks so humans can read it. APIs usually return minified JSON on a single line to save bytes; formatting it is the first step when you debug a response, review a config file or write documentation. This tool also works the other way: Minify removes every unnecessary space and newline for the smallest possible payload.
Formatting and validation go hand in hand. The formatter parses your input with the same strict rules as JSON.parse(), so anything it accepts will be accepted by any standards-compliant parser (RFC 8259).
Common JSON errors and how to fix them
When parsing fails, the validator reports the exact line and column, highlights the character and explains the problem. These are the mistakes it catches most often:
| Error | Invalid | Valid |
|---|---|---|
| Trailing comma | [1, 2, 3,] | [1, 2, 3] |
| Single quotes | {'id': 1} | {"id": 1} |
| Unquoted key | {id: 1} | {"id": 1} |
| Comments | {"a": 1 // note} | Remove the comment |
| Missing comma | {"a": 1 "b": 2} | {"a": 1, "b": 2} |
| Special numbers | NaN, Infinity, 01 | null, 1 |
| Raw line break in string | "line 1⏎line 2" | "line 1\nline 2" |
Many of these are legal in JavaScript object literals, JSON5 or YAML but not in JSON — a common source of confusion when copying data out of source code.
Warnings beyond syntax
Some JSON is technically valid but still risky. The validator warns about duplicate keys (most parsers silently keep only the last value) and about integers larger than 253 (9,007,199,254,740,991), which JavaScript cannot represent exactly — a frequent problem with 64-bit database IDs. If you see that warning, send such IDs as strings.
Beautify vs. minify: which should you use?
Use beautified JSON for anything people read: config files in Git (so diffs are line-based), documentation and debugging. Two-space indentation is the most common convention in JavaScript projects; four spaces is typical in Python's json.dumps(indent=4). Use minified JSON for network payloads and storage. Note that gzip or Brotli compression on your server already removes most of the size difference, so readability usually wins for files you commit.
Tree view and key sorting
For large documents, the Tree view lets you collapse objects and arrays and see item counts at a glance. Sort keys orders every object's keys alphabetically at all levels — handy for comparing two JSON documents in the Diff Checker, since key order otherwise produces noisy diffs. Need a different format? Convert to YAML, CSV or TypeScript types.
Tools that pair well with the JSON Formatter
- JavaScript Formatter — Unminify and pretty-print JavaScript, JSON or JSX with your preferred indentation and brace style — or strip whitespace and comments with a verified minifier.
- Base64 Encode / Decode — Convert text to Base64 and back with full UTF-8 support (accents, emoji), switch to URL-safe Base64, or drop a file to get its Base64 string or data URI.
- CSV to JSON — Paste CSV or TSV and get a JSON array of objects.
- JSON to Markdown Table — Turn API responses or LLM-generated JSON arrays into a clean, aligned Markdown table for READMEs, docs and pull requests.
Frequently asked questions
Is my JSON uploaded to a server?
Why does the validator reject comments and trailing commas?
tsconfig.json) and YAML do — but a strict parser like JSON.parse() will throw an error.How large a file can I format?
Does formatting change my data?
What is the difference between JSON and a JavaScript object?
undefined, comments and trailing commas are not allowed.