PrettifyPrettify

JSON Formatter: Prettify and Pretty Print JSON

Paste minified or messy JSON and get readable, indented output. This JSON formatter will prettify JSON in your browser, keep every key in its original order, and name the line of any syntax error. Use it when you need to pretty print JSON before you read it, share it, or paste it into a ticket.

Result
The formatted result shows here as you paste.
Runs in your browser. Nothing is uploaded.

What the JSON formatter does

A JSON formatter adds line breaks and indentation to a document. The data does not change. The same keys, values, and order come out as went in. On this page, prettify JSON, pretty print JSON, and format JSON all name that one job.

You paste one JSON object or array. You get the same data with one value per line and an indent of two spaces. The indent is fixed, so there is nothing to configure.

The page is a formatter, not a checker. If the text does not parse, you see the line and column of the first error instead of output.

Key features

Formatting is only useful if the output is safe to use. A formatter that reorders keys or rounds numbers changes your data. These details decide whether the Prettify output is safe.

  • Key order stays as you wrote it. Prettify sorts keys only when you select Sort Keys in the editor.
  • Numbers keep their digits. A 19-digit ID, the float 49.0, and a long decimal come out exactly as they went in.
  • Unicode escapes in strings are decoded. The text \u00e9 comes out as the character é.
  • Empty objects and arrays stay on one line, as {} and [].
  • Every array item gets its own line, so a long list of numbers makes a tall result.
  • Comments and trailing commas are removed. The box reads JSONC, writes strict JSON, and tells you what it removed.
  • The Result panel shows the first 400 lines. Copy and Download include the whole output.

How to prettify JSON

The box at the top of this page does the whole job. It runs in your browser and takes documents up to 512 KB. Larger documents go straight to the editor.

  1. Paste your JSON into the box at the top of this page, or select Try an example.
  2. Read the summary line above the result. It gives the shape, such as Object with 8 keys, 3 levels deep.
  3. Read the formatted text in the Result panel. It is highlighted and indented by two spaces.
  4. Select Copy to put the text on your clipboard, or Download to save a file named prettify.json.
  5. To keep working, select Open in full editor. It opens in the Raw view.
  6. In the editor, select Sort Keys, under the Transform group, to order every key from A to Z.

Worked example: pretty print a minified order

Say a service returns an order on one line. The input below has a price written as 49.0, an escaped é, an empty list, and an empty object.

The result is the same data on 24 lines. Prettify keeps 49.0 as written, turns the escape into the real character, and leaves the empty tags and meta values on one line each. The keys stay in their original order, and the summary reads Object with 8 keys, 3 levels deep.

Input
{"orderId":"A-1001","customer":{"name":"Ana Ruiz","email":"ana@example.com"},"items":[{"sku":"KB-01","qty":1,"price":49.0},{"sku":"MS-07","qty":2,"price":19.5}],"coupon":null,"note":"caf\u00e9","paid":true,"tags":[],"meta":{}}

Result
{
  "orderId": "A-1001",
  "customer": {
    "name": "Ana Ruiz",
    "email": "ana@example.com"
  },
  "items": [
    {
      "sku": "KB-01",
      "qty": 1,
      "price": 49.0
    },
    {
      "sku": "MS-07",
      "qty": 2,
      "price": 19.5
    }
  ],
  "coupon": null,
  "note": "café",
  "paid": true,
  "tags": [],
  "meta": {}
}

Formatting JSON that has comments

Config files such as tsconfig.json allow comments and trailing commas. Strict JSON does not, and most parsers reject both. If you paste such a file, the box formats it as strict JSON and removes the extras.

A note under the summary says what it removed. For example: The input was JSONC, not strict JSON (it uses comments and trailing commas). The formatted output is strict JSON, with those removed. Check the output before you replace the original file, because the comments are gone from it.

Common use cases

People format JSON to read it, and also to make it easier to review. The formatter is often the first step: you format the text, then read it, share it, or hand it to another tool. These are the jobs it handles most.

  • Read a minified API response or a single log line.
  • Put each field on its own line before you paste a payload into a bug report.
  • Make a config file diff cleanly, because every value sits on its own line.
  • Rewrite a JSON file with one style before you commit it, so later changes show as small diffs.
  • Strip comments and trailing commas from a JSONC file.

Frequently asked questions

Is this the same as Prettier?

No. Prettify formats JSON with its own writer, which uses a fixed two-space indent and keeps large numbers exact. Prettify uses the Prettier library only for Markdown, MDX, and HTML documents.

Can I minify JSON or change the indent?

No. Prettify has no minify action and no indent setting. The output always uses two-space indents, with one value per line.

Does formatting change my data?

No. Keys stay in order, and strings, numbers, and null keep their values. Only the whitespace changes, and \u escapes in strings become the characters they stand for. In a JSONC file, comments and trailing commas are removed, and single quotes become double quotes.

Why do I get an error instead of formatted JSON?

The text does not parse as JSON. The box shows the line and column of the first error. Select Fix it in the editor to open the paste dialog, which can repair mistakes such as unquoted keys and missing commas.

Is this JSON formatter free?

Yes. Formatting, the Tree, Raw, and Table views, search, Sort Keys, and format conversion are free, with no sign-up. Pro adds tools such as jq and Diff, which you do not need to format a document.

Is my JSON sent anywhere when I format it?

No. The page parses and writes your JSON in the browser, so a response with tokens or customer fields stays on your device. The page sends none of your text anywhere.

Related tools