Skip to content

JSON formatter

Pretty-print or minify one JSON value. Invalid input is not repaired.

Ctrl+Enter or ⌘+Enter runs this tool immediately.

Output
Indent
Keys
JSON input
Formatted JSON

Waiting for input.

Parsing stays in this browser. Input is not uploaded or saved.

How to use this tool

  1. Paste JSON. The sample is intentionally minified so pretty-printing is easy to see.
  2. Choose Pretty and an indent of 2 or 4 spaces, or choose Minify. Choose Sorted to order object keys.
  3. Copy or download only after the status reports that formatting succeeded.

Supported formats and limitations

  • Formatting changes whitespace, not values. Key order stays as parsed unless you choose Sorted.
  • Trailing commas, comments, and single-quoted strings are invalid JSON and are not stripped for you.
  • Pretty output ends with a newline. Minified output does not add one.
  • An integer past the safe range is still formatted, with a notice that the JSON number may already be imprecise.

Examples

Minify a small object

Newlines and indentation are removed. Strings and numbers stay the same.

{
  "ok": true,
  "n": 1
}

Pretty-print a list

Each array element is placed on its own line at the indent you chose.

[1, null, false, "ok"]

Common errors and solutions

Unexpected token ]
Remove the trailing comma before the closing bracket. JSON does not allow it.
Unterminated string
Close the double quote. Escaped quotes inside the string use a backslash.
Unexpected non-whitespace character after JSON
Delete the extra text after the value, or split the file so only one JSON value remains.

FAQ

Does minify change numbers or key order?
Minify removes insignificant whitespace. Keys stay in the parsed order unless you choose Sorted. Array order is never sorted.
What happens if the JSON is empty?
The formatter waits. It does not invent {} or [].
Can I format JSON that contains secrets?
The text stays in the browser. Do not paste it into a page that you do not trust, including this one if you have added your own scripts later.

Related tools

  • JSON Schema validator

    Check a JSON document against a JSON Schema in the browser. Draft-07 and 2020-12 are supported, and remote $ref values are not fetched.

  • JSON to CSV converter

    Convert a JSON array of objects or arrays to CSV in the browser. Nested values are rejected instead of being encoded.

  • JSON to YAML converter

    Convert valid JSON into YAML with 2-space or 4-space indentation. Nested objects, arrays, and multiline strings are preserved, and invalid JSON is reported instead of repaired.