How this calculation works
The JSON Formatter & Validator parses raw JSON payloads, inspects syntax validity, calculates structural metrics, and renders beautified or minified JSON outputs.
Mathematical formula and logic
Validation via RFC 8259 ECMAScript JSON Parser. Beautified = JSON.stringify(JSON.parse(data), null, indent).
Worked example
Formatting a minified 5-key payload with 2 spaces indents nested arrays, validates JSON grammar, and reports byte size savings under minification.
Calculation assumptions
- Strict JSON compliance (double-quoted keys, no trailing commas, no single quotes).
- UTF-8 text encoding.
Frequently asked questions
Why is trailing comma invalid in JSON?
The official RFC 8259 JSON specification strictly forbids trailing commas after the last element in arrays or objects, unlike JavaScript object literals.
What data types are supported in JSON?
JSON supports six core data types: String, Number, Boolean, Null, Object (key-value pairs), and Array (ordered list).
Can JSON store functions or undefined values?
No, functions, `undefined`, and Symbols cannot be represented in standard JSON and are dropped during serialization.
How much bandwidth does JSON minification save?
Minifying JSON by stripping whitespace, indentation, and newlines typically reduces payload size by 20% to 40%, accelerating API responses.
What is the difference between JSON and JSON5?
JSON5 is an extension that permits comments, unquoted keys, single-quoted strings, and trailing commas, but it requires specialized parsers.