Skip to content
GigAI Tools
6 steps

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.

Open JSON Formatter

Follow these steps

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Frequently asked questions