JSON Standards⏱️ 7 min readUpdated: 2026-08-19

JSON Syntax Explained: Grammar, Types & RFC 8259 Rules

Deep dive into RFC 8259 JSON syntax rules. Learn precise escaping sequences, string encoding, number formatting, and bracket balancing to write valid JSON.

The RFC 8259 Grammar Specification

The Internet Engineering Task Force (IETF) defines the JSON standard in RFC 8259. Unlike flexible scripting languages like JavaScript, JSON is a strict data representation format with deterministic grammar rules.

String Escaping Rules

Strings in JSON must be wrapped in double quotes and encoded in UTF-8. Certain characters must be escaped with a preceding backslash (\):

CharacterEscape SequenceMeaning
"\"Quotation mark
\\\Reverse solidus (Backslash)
/\/Solidus (Forward slash - optional)
Backspace\bBackspace control code
Form feed\fForm feed control code
Newline\nLine feed (LF)
Carriage return\rCarriage return (CR)
Tab\tHorizontal tab
Unicode\uXXXX4-digit hexadecimal Unicode point

Number Representation Rules

JSON numbers adhere to standard mathematical notations with strict constraints:

{
  "integer": 42,
  "negative": -100,
  "fraction": 3.14159265,
  "scientific_positive": 1.25e6,
  "scientific_negative": 4.8e-3
}

Disallowed: NaN, Infinity, -Infinity, hexadecimal numbers (0xFF), and octal numbers (077) are invalid in JSON.

Objects vs. Dictionaries

A JSON object represents a key-value map where each key is a unique string. While the specification allows duplicate keys, RFC 8259 warns that behavior is unpredictable across parsers. Always ensure object keys are distinct:

// Correct:
{
  "hostname": "api.toolnest.dev",
  "port": 443,
  "tlsEnabled": true
}

Try Related Tools on ToolNest

Frequently Asked Questions