JSON Formatter

Pretty print JSON with the indentation you want

Indentation

Input (JSON)

Formatted

Valid JSON: object with 7 keys

JSON Formatter guide

APIs, logs, and config files often hand you JSON on one long line. The JSON Formatter re-indents it so you can read the structure, spot missing fields, and compare values, and if the JSON is broken it points to the exact line.

Options

  • Indentation. 2 spaces is the most common style and the default. 4 spaces is easier to follow in deeply nested data, and tabs let each reader's editor choose the width.
  • Sort keys A to Z. Orders the keys of every object alphabetically, which makes two versions of the same data easier to compare. Array order never changes.

What changes when you format

Formatting changes whitespace only, apart from a few things that come from how JSON is read:

  • Number style. 1.0 becomes 1 and 1e2 becomes 100, because they are the same number.
  • Escapes. \u00e9 is written as é.
  • Large integers. Very large integers, beyond 9,007,199,254,740,991, lose precision when JSON is read. The tool shows a note when that happens; store long IDs as strings to keep every digit.
  • Duplicate keys. Only the last value is kept, and the tool shows a note naming the key.

Example

{"id":1042,"roles":["admin","editor"]}

// formatted with 2 spaces

{
  "id": 1042,
  "roles": [
    "admin",
    "editor"
  ]
}

Frequently asked questions

How do I pretty print JSON?
Paste it into the input. The formatted version appears on the right straight away, indented with 2 spaces by default and ready to copy.
Should I use 2 or 4 spaces for JSON?
Either is valid. 2 spaces is the most common; 4 spaces is easier to follow in deeply nested data. Pick one per project and stay consistent.
Is my JSON sent to a server?
No. Formatting runs in your browser, so the data never leaves your device. That makes it safe for API responses that contain personal data or tokens.
Why did a large ID number change?
JavaScript numbers are exact only up to 9,007,199,254,740,991. Bigger integers are rounded when the JSON is read, and the tool shows a note when that happens. Store long IDs as strings to keep every digit.