Developer guide
How to format JSON without changing its data
JSON formatting adds indentation and line breaks outside strings so nested objects and arrays become easier to read while the represented values stay intact.
Open the JSON FormatterWhat JSON formatting changes
A formatter changes whitespace outside strings. It can place object members and array items on separate lines and indent each nesting level. Spaces inside string values remain data and must not be changed.
The ToolPixels formatter preserves number spellings, large integer text, key order, duplicate keys, and escape sequences. It does not sort keys or repair invalid input.
How to format JSON
- Paste JSON or open a JSON file.
- Choose two spaces, four spaces, or tabs.
- Select Format JSON.
- If an error appears, jump to the reported location and correct the syntax.
- Copy or download the formatted result.
Use two spaces when compact diffs matter and four spaces when deeper visual separation is helpful. Follow the repository's existing convention.
A JSON formatting example
Input
{"name":"ToolPixels","tags":["web","tools"]}
Two-space output
{
"name": "ToolPixels",
"tags": [
"web",
"tools"
]
}
Valid JSON rules to remember
- Property names and strings use double quotes.
- Members and array items need commas, but the final item cannot have a trailing comma.
- Comments are not part of standard JSON.
undefined,NaN, andInfinityare invalid.- Top-level strings, numbers, booleans, and
nullare valid JSON too.
Formatting, minifying, and validating
| Action | Result |
|---|---|
| Format | Add readable whitespace |
| Minify | Remove unnecessary whitespace |
| Validate | Check syntax and report the first error |
None of these checks whether the values meet an application's business rules. Use JSON Schema or application validation for that.
Try it with ToolPixels
Format, minify, or validate JSON in the browser without uploading the document.