JSON Formatter
Validate, pretty-print, and minify JSON instantly.
Paste your JSON in the input box. Choose an indent size, then hit Format to pretty-print or Minify to compress it.
Buttons
- Format — validates and pretty-prints with your chosen indentation
- Minify — strips all whitespace to the smallest possible size
- Swap — moves the output back into the input for chained operations
- Clear — resets both fields
This tool parses your JSON text and checks its syntax. Format re-prints it with consistent indentation so nested structures are easy to read. Minify strips all whitespace to the smallest possible size — same data, fewer bytes, useful for APIs and storage. Swap moves the output back into the input so you can chain operations.
JSON syntax rules
Keys must be double-quoted strings. Values can be string, number, true/false, null, {} (object), or [] (array). Trailing commas and comments are not valid JSON.
Common errors
Unquoted keys: {key: "val"} → must be {"key": "val"}. Single quotes: {'a': 1} → double quotes required. Trailing comma: [1, 2,] → illegal in JSON. Comments: JSON has no comment syntax.
Indent options
2 spaces is the most widely used convention. 4 spaces is common in Python and Java projects. Tab uses semantic indentation that editors can display at any width. All three produce valid, identical JSON.
Parse then stringify
Formatting works by parsing your text into a data structure, then stringifying it back. This is why formatting also validates — it can only re-print JSON it successfully parsed. Invalid JSON produces an error, not garbled output.