Skip to content
Utilerio

JSON Formatter

Pretty-print or minify JSON, with the exact position of any syntax error.

0

Formatted JSON

The result will appear here.

Was this tool useful?

About this tool

JSON that comes out of an API is almost always minified: one line, no spaces, impossible to read. Formatting it adds the indentation and line breaks that let you follow the structure, and minifying it again strips them for transport.

The formatter also acts as a parser. If the document is not valid JSON it cannot be reformatted, so you get the line and column where parsing failed instead of a silent no-op — which is usually the fastest way to find a missing comma or a trailing one.

How to use it

  1. Paste the JSON, or upload a .json file.
  2. Pick an indentation style. Two spaces is the common default; tabs are useful if your editor is configured that way.
  3. Press Format to expand the document, or Minify to strip every optional character.
  4. Turn on key sorting when you want to diff two documents that contain the same data in a different order.
  5. Copy the result or download it as a .json file.

Examples

Minified input, formatted output

{"sku":"TL-001","price":19.9,"tags":["label","roll"]}
{
  "sku": "TL-001",
  "price": 19.9,
  "tags": [
    "label",
    "roll"
  ]
}

Common problems

“Unexpected token” at the very end of the document.
Usually a trailing comma after the last item in an object or array. JSON does not allow it, unlike JavaScript.
The document uses single quotes and is rejected.
That is a JavaScript object literal, not JSON. JSON requires double quotes around both keys and string values.
Large numbers change slightly after formatting.
JSON numbers are parsed as IEEE 754 doubles, which cannot represent every 64-bit integer exactly. Systems that need exact large IDs send them as strings.

Frequently asked questions