Complete guide to JSON formatting and validation
By TabBenchHow we check our guides
JavaScript Object Notation (JSON) is the universal data interchange standard powering modern web APIs, cloud microservices, and configuration files. Defined formally in RFC 8259 and ECMA-404, JSON is lightweight, language-agnostic, and straightforward for computers to parse.
However, JSON's strict specification makes it unforgiving: a single misplaced comma, an unescaped control character, or a single quotation mark will cause strict parsers in Node.js, Python, or Go to crash immediately with a fatal syntax exception.
Step by step
Understand the strict double-quote requirement
Unlike standard JavaScript or Python dictionaries, JSON specifications mandate that all object keys and all string values MUST be enclosed in double quotation marks (`"key": "value"`). Single quotes (`'key'`) are strictly illegal.
Eliminate trailing commas
Trailing commas after the final element in an array (`[1, 2, 3,]`) or the final key-value pair in an object (`{"a": 1,}`) violate the JSON grammar specification and are the #1 cause of API validation failures.
Indent nested structures for human readability
Use a JSON Beautifier to format minified single-line API responses with consistent 2-space or 4-space indentation, making nested hierarchy, arrays, and null values immediately obvious to developers.
Minify JSON before transmitting over networks
When deploying configuration payloads or transferring large datasets across network sockets, minify the JSON to strip all whitespace, indentation, and newline characters, reducing payload size by 20% to 35%.
Things worth knowing
- JSON supports only six data types: String, Number, Boolean, Null, Object, and Array. Functions, undefined, and Date objects are not valid JSON.
- Numbers in JSON cannot have leading zeros (`012` is invalid) and cannot represent `NaN` or `Infinity`.
- Keys inside JSON objects must be unique strings; duplicate keys lead to unpredictable parser behavior across different languages.
- Always validate configuration files (like `tsconfig.json` or `settings.json`) before committing code to prevent broken CI/CD pipelines.
Frequently asked questions
Why does JSON not support comments?
How do I represent dates in JSON?
What is the difference between JSON and JSON5?
Can JSON safely contain customer passwords or API secrets?
Related tools
JSON to CSV Converter
Convert JSON arrays to CSV, and CSV back to JSON.
JSON to TypeScript Converter
Generate TypeScript interfaces from a JSON sample.
AI JSON Explainer
Get a plain-English walkthrough of what a JSON payload contains.
Optional cloud mode
Base64 Encoder & Decoder
Encode text or files to Base64, or decode Base64 back to text or a file.