Skip to content
TabBench

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.

Open the JSON FormatterFree, no sign-up, and your file never leaves your browser.

Step by step

  1. 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.

  2. 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.

  3. 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.

  4. 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?

Douglas Crockford deliberately removed comments from the JSON standard in 2000 to prevent developers from putting parsing instructions or proprietary directives inside data payloads.

How do I represent dates in JSON?

JSON has no native Date type. The universally accepted standard is to serialize dates as ISO 8601 UTC strings: `"2026-09-13T10:30:00Z"`.

What is the difference between JSON and JSON5?

JSON5 is an expanded proposed standard that permits comments, single quotes, trailing commas, and hexadecimal numbers. However, standard web APIs still strictly expect vanilla JSON.

Can JSON safely contain customer passwords or API secrets?

Plain JSON offers zero encryption. Any secrets stored in JSON files or API responses must be encrypted at rest and transmitted over secure TLS (HTTPS) connections.