Input
Output
Empty Formatting runs in your browser

Online JSON Formatter

Paste messy or minified JSON and get clean, consistently indented JSON back as you type. The JSON formatter checks the syntax at the same time, so you know the result is valid, and points to the exact line of any error. Choose the indentation, preview the output, and copy or download it.

How to format JSON online

  1. Paste your JSON into the left editor. You can also open a .json or .txt file with Open file (Ctrl+O) or drop a file onto the page.
  2. The formatted JSON appears on the right in the Preview view as you type. With Live turned off, press Format or Ctrl+Enter.
  3. Use the Indent selector to set how many spaces each level is indented. Two is the usual choice.
  4. Press Copy or Download, or switch the output to the Code or Tree view to keep working on it.

What a JSON formatter does

JSON from an API, a log file or a database is usually minified: one long line with no spaces. That is efficient for computers but almost impossible for people to read. A JSON formatter, also called a JSON pretty printer, parses the text and writes it back out with one key per line and each level of nesting indented, so you can see the structure at a glance.

Formatting only touches the whitespace between values. Keys keep their order, strings keep their exact content, and numbers are written the way they were. The formatted JSON is the same data as the original, just easier to read, review and diff.

Because the formatter has to parse the JSON first, it is also a quick validity check. If the input is broken, you get the line and column of the first error rather than a silently wrong result.

Before and after

This minified response:

{"id":1042,"status":"shipped","items":[{"sku":"A-1","qty":2},{"sku":"B-7","qty":1}],"paid":true}

becomes:

{
  "id": 1042,
  "status": "shipped",
  "items": [
    { "sku": "A-1", "qty": 2 },
    { "sku": "B-7", "qty": 1 }
  ],
  "paid": true
}

Choosing an indentation style

Pick whichever matches the files in your project. Parsers ignore indentation completely, so it is purely a readability choice.

Format JSON in your own tools

When you are not in a browser, these do the same job:

The online formatter is quicker when the JSON is already on your clipboard, when you want to see it as a tree, or when you are on a computer where you cannot install anything.

When formatting fails

If the formatter reports an error, the input is not valid JSON. The usual suspects are a comma after the last item, single quotes instead of double quotes, keys without quotes, and comments. The JSON Validator explains each error in more detail, and JSON Repair fixes most of them automatically. If the input is a JSON value that was turned into a string, with backslashes before every quote, use the JSON Parser to decode it first.

More than a formatter

Free and private

The JSON formatter is free, needs no account and has no usage limits. Formatting happens in your browser, so your data is never uploaded, and the tool keeps working with files of several megabytes because there is no server round trip.

Frequently asked questions

What does a JSON formatter do?

A JSON formatter takes compact or messy JSON and rewrites it with consistent line breaks and indentation, one key per line, so the structure is easy to read. It also checks the syntax, so you know the JSON is valid before you use it.

How do I pretty print JSON?

Paste the JSON into the left editor and the pretty printed version appears on the right. Use the indent selector to choose how many spaces each level is indented, such as 2 or 4.

What indentation should I use for JSON?

Two spaces is the most common choice and matches the default of most JavaScript tools and APIs. Four spaces is common in Python projects. JSON parsers ignore indentation, so it only affects readability.

Does formatting change my data?

No. Formatting only changes whitespace between values. Keys, values and their order stay exactly the same, and the formatted JSON parses to the same data as the original.

Can I format a large JSON file?

Yes. Files of several megabytes format in about a second on a typical computer, because the work happens in your browser rather than on a server.

How do I format JSON in my code instead?

In JavaScript use JSON.stringify(value, null, 2). In Python use json.dumps(value, indent=2). On the command line, jq . file.json or python -m json.tool file.json both pretty print a file.

Download JSON

Save to this browser

Saves both the input and the output. Stored only in this browser on this device; use Export in Saved to back it up.

Share

Anyone with the link can see this JSON. Leave out passwords, tokens and personal data.

Shares the input and the output together.

Editor settings

Type

{
  "id": 1024, "name": "Ada", "active": true,
  "tags": ["0O", "1lI", "=> != >="], "manager": null
}

Colour theme

Code editor

Defaults

Saved JSON

    Nothing saved yet

    Press Ctrl+S or use Save on the toolbar to keep JSON here. It stays in this browser and is never uploaded.

    Stored in this browser only, not in an account. Saved JSON and links are lost if you clear your browsing data, use a private window, switch browser or device, or the browser frees up space. Use Export all now and then to keep a copy.

    Send feedback

    How is online-json working for you?