Use formatting when a JSON response or configuration is difficult to read on one line. The example contains a string, a boolean and an array. The formatter first parses the input, so invalid JSON produces an error rather than a partly formatted result.
Example input
{"name":"Ada","active":true,"roles":["reader","editor"]}Expected result
{
"name": "Ada",
"active": true,
"roles": [
"reader",
"editor"
]
}Try it step by step
- Keep the format operation selected and inspect the prefilled JSON object.
- Run the formatter and compare the two-space indentation with the expected result.
- Try the compact operation, then introduce a trailing comma to see a validation error.
How to read the result
Line breaks and indentation make the object easier to inspect without changing the example values. JSON requires double-quoted property names and strings. Comments, trailing commas and undefined are not valid JSON. A parser can also replace duplicate property names with their last value.
Limits and important details
Parsing uses JavaScript number precision and may round large integer identifiers. Store such identifiers as strings. Formatting is not a byte-preserving transformation, so do not use it on signed payloads that require exact original bytes.