JSON Grammar & Syntax Diagrams
Interactive railroad diagrams visualizing the official JSON specification
Live JSON Parser Visualization
Type or paste JSON below to see which grammar rules are applied in real-time:
Enter JSON to see the parsing visualization
Terminal (literal characters)
Non-terminal (grammar rule)
Rail (path)
Active (currently parsing)
value
Root RuleA JSON value can be a string, number, object, array, boolean, or null:
value ::= string | number | object | array | "true" | "false" | "null"
object
ContainerAn object is an unordered set of name/value pairs enclosed in curly braces:
object ::= "{" ws [ member ( "," member )* ] ws "}"
member ::= string ws ":" value
array
ContainerAn array is an ordered collection of values enclosed in square brackets:
array ::= "[" ws [ value ( "," value )* ] ws "]"
string
PrimitiveA string is a sequence of Unicode characters wrapped in double quotes:
string ::= '"' character* '"'
character ::= unescaped | '\' ( " | \ | / | b | f | n | r | t | u hex{4} )
number
PrimitiveA number can be an integer, decimal, or use scientific notation:
number ::= "-"? ( "0" | digit1-9 digits* ) ( "." digits+ )? ( [eE] [+-]? digits+ )?
whitespace
UtilityWhitespace can be inserted between any pair of tokens:
ws ::= ( ' ' | '\t' | '\n' | '\r' )*
Official JSON Specifications
JSON is defined by two complementary standards: