How to Format JSON (Pretty-Print & Validate)
Turn a minified or broken JSON string into clean, indented, readable JSON, and catch syntax errors while you're at it. A quick step-by-step guide.
Raw JSON from an API or a config file often arrives as one long, unbroken line with no whitespace. It's valid, but it's almost impossible to read, nested objects blur together and a single misplaced comma can be hard to find. Formatting (also called pretty-printing or beautifying) re-indents the data so every key, value and nesting level lines up on its own row.
Formatting also doubles as validation: a formatter can only lay out JSON that actually parses, so if it refuses, you've found a syntax error. The guide below uses our free JSON formatter, which runs entirely in your browser. Your data is never uploaded, so it's safe to paste even sensitive payloads.
This guide uses JSON Formatter
Free, private and instant. Open it now and follow along with the steps below.
Follow these steps
Step 1: Open the JSON formatter
Go to the JSON formatter tool. It loads instantly in the browser with nothing to install and no account needed.
Step 2: Paste your JSON
Paste the raw JSON into the input box, a minified API response, a copied config snippet, or anything in between. You can also type it directly if you're building a payload by hand.
Step 3: Choose your indentation
Pick how much to indent each level. Two spaces is the most common convention, four spaces is more spacious, and tabs suit some editors. This controls how the formatted output looks.
Step 4: Format the JSON
Run the formatter. It parses the input and re-emits it with consistent indentation, one property per line, so the structure becomes immediately scannable.
Step 5: Fix any reported errors
If the JSON is invalid, the tool points to the problem, a trailing comma, a missing bracket, or unquoted keys. Correct it and format again until it parses cleanly.
Step 6: Copy or download the result
Copy the pretty-printed JSON to your clipboard, or download it as a .json file to drop straight into your project or documentation.
Tips & best practices
- JSON keys and strings must use double quotes. Single quotes are the single most common cause of 'invalid JSON' errors.
- Trailing commas after the last item in an object or array are not allowed in strict JSON, even though many languages permit them.
- If you need the smallest possible size for transport, format to read it, then minify the final version, indentation adds bytes you don't want to ship.
- Comments aren't part of the JSON spec. If your file has // or /* */ comments it's really JSON5 or JSONC, and a strict formatter will reject them.
Related tools
JSON Validator
Validate JSON against RFC 8259 with the exact error line, column and a caret under the bad character. Get plain-English explanations, one-click auto-fix for trailing commas and single quotes, plus depth, key-count and type stats, nothing uploaded.
JSON to CSV
Convert JSON to CSV in your browser. Paste an array of objects and get a spreadsheet-ready CSV with a header row, automatic flattening of nested keys, and a choice of comma, semicolon or tab delimiter. Copy or download instantly. Nothing is uploaded.
CSV to JSON
Convert CSV to JSON in your browser. Paste or drop a.csv and get a clean array of objects or arrays with a header toggle, optional number/boolean type inference and pretty or minified output. Nothing is uploaded.
JSON to TypeScript
Convert JSON to TypeScript interfaces or types instantly, with merged unions across array items, optional-from-null, readonly, export and naming controls, 100% in your browser.
Related how-to guides
- How to Convert CSV to JSON (Free, In Your Browser)Turn a spreadsheet or CSV export into a clean array of JSON objects, with the right headers as keys and correct data types. A step-by-step guide.7 steps
- How to Decode a JWT (Read Its Header & Payload)Paste a JSON Web Token and read its header and claims in plain JSON, inspect the algorithm, expiry and scopes while debugging auth. A safe, browser-only guide.6 steps
- How to Create a QR Code (Free, No Sign-Up)Generate a scannable QR code for any link, text or contact in seconds, free, high-resolution, no watermark. A step-by-step guide to making a QR code.6 steps