WebTool

JSON Essentials · Ch. 1

JSON Syntax Basics: Six Data Types and the Five Most Common Mistakes

WebTool Team · Published 2026-09-08 · JSON / Syntax / Beginner

JSON has exactly six data types: string, number, boolean, null, object, and array. It is a "data format," not a "JavaScript subset" — no comments, no trailing commas, and strings must use double quotes. After writing JSON, validate it with our JSON formatter & validator.

The six data types

{
  "string": "must use double quotes",
  "number": 3.14,
  "boolean": true,
  "null": null,
  "object": { "nested": "objects can nest" },
  "array": [1, "mixed", false]
}
  • Numbers have no integer/float distinction, and NaN, Infinity, and hexadecimal are not supported.
  • Object keys must be strings (wrapped in double quotes) and should not repeat — behavior with duplicate keys depends on the parser, though most take the last value.

JSON vs. JavaScript objects

Feature JavaScript object JSON
String quotes Single or double Double only
Key quotes Optional Required
Trailing comma Allowed Forbidden
Comments Allowed Forbidden
undefined / functions Allowed Forbidden

The five most common mistakes

  1. Trailing comma: {"a": 1,} — no comma after the last item of an object or array.
  2. Single quotes: {'a': 1} — switch everything to double quotes.
  3. Comments: {"a": 1 /* note */} — if you need comments, use JSON5 or YAML instead.
  4. Unquoted keys: {a: 1}.
  5. Multi-line strings: a JSON string cannot span lines directly; write line breaks as \n.

Debugging tip

Parse errors usually report a line and column, but the real mistake is often just before the reported position — miss a comma on line 3 and the parser only notices on line 4. Looking one or two lines above the error is the fastest way to find JSON syntax mistakes.

Last updated: 2026-09-08