Skip to the tool
GigaJSON

JSON Formatter

All tools
Format and check
View and query
Convert
JSON to code
Encode and decode
Sample files
Guides Open GigaJSON
Input JSON
Output JSON

The JSON output appears here as you type.

Ready Runs in your browser

Paste JSON or open a file up to 1 GB to format (pretty print) it. Choose 2 or 4 spaces, and sort the keys if you want. If the JSON is invalid, you get the line and column of the problem and a Repair button. To make JSON smaller instead, use the JSON Minifier.

How to use it

  1. Paste JSON into the input, drop a file on it, or click "Open file".
  2. Pick the indentation (2 or 4 spaces) and whether to sort keys.
  3. Copy the formatted JSON or download it.

Read more: How to open a JSON file on Windows, Mac, a phone or in Excel · How to fix invalid JSON: the 10 most common errors

Private, and made for big files

This tool runs in your browser, in a background worker: nothing you paste or open is uploaded, and nothing is kept after you leave. JSON and XML input can be up to 1 GB, depending on available memory. Processing runs in a background worker; large analyses can take a minute or more. Already loaded features keep working if your connection drops. Loading another tool or jq for the first time needs a connection. When one tool isn't enough, GigaJSON opens your data with a tree, a table, JSONPath/JMESPath/jq queries, transforms, diff and history.

Format a one-line API response

APIs and log files often send JSON on a single line. Paste this:

{"id":"ord_002","status":"pending","total":149,"customer":{"name":"Sam","country":"NO"},"items":[{"sku":"MS-02","qty":2},{"sku":"KB-01","qty":1}]}

With 2 spaces, the formatter puts each key on its own line and indents each level:

{
  "id": "ord_002",
  "status": "pending",
  "total": 149,
  "customer": {
    "name": "Sam",
    "country": "NO"
  },
  "items": [
    {
      "sku": "MS-02",
      "qty": 2
    },
    {
      "sku": "KB-01",
      "qty": 1
    }
  ]
}

The values and their order don't change, only the spacing. Pick 4 spaces for deeper indentation, or tick Sort keys to put every object's keys in alphabetical order, which makes two versions of the same data easier to compare in JSON Diff. To go the other way and remove the whitespace, use the JSON Minifier.

If the formatter reports an error instead, the text isn't valid JSON yet. The message gives the line and column; JSON Repair fixes the common causes, and how to fix invalid JSON explains each one.

Questions

What does a JSON formatter do?

It rewrites JSON with consistent line breaks and indentation, so nested objects and lists are easy to read. The data stays the same.

Is my data uploaded?

No. The tool runs in your browser, in a background worker. Nothing you paste or open goes to a server, and nothing is kept after you leave the page.

How large a file can it handle?

JSON, XML and CSV input can be up to 1 GB, depending on memory. YAML input and JSON repair are limited to 128 MB. Formatting runs in a background worker. jq, text editing and text-based exports have separate limits, shown when you use them.

My JSON is invalid. What now?

The formatter shows the line and column of the error and offers "Repair". It fixes the usual problems: missing quotes or commas, trailing commas, comments and cut-off JSON.

What is the difference between formatting and validating?

Formatting changes the spacing so JSON is easier to read. Validating only checks that the text is valid JSON. The formatter validates as it goes: it can only format text that parses, and it shows the error when the text doesn't.

Should I use 2 or 4 spaces?

Either is valid JSON, and the data is the same. 2 spaces is the most common for JSON files and API documentation. 4 spaces is easier to follow when the nesting is deep.

Can it format a file that is too big for other formatters?

Yes. Pasting tens of megabytes into a text box makes most online formatters freeze. Here you open the file instead, and it is formatted in a background worker, up to 1 GB. The page shows the first 1 MB of the result, and Download saves all of it.

All tools