[From wikipedia…]


A compact cheat sheet (actually written in YAML) as well as a full specification are available at the YAML web site. The following is a synopsis of the basic elements.

  • YAML streams are encoded using the set of printable Unicode characters, either in UTF-8 or UTF-16.
  • Whitespace indentation is used to denote structure; however tab characters are never allowed as indentation.
  • Comments begin with the number sign ( # ), can start anywhere on a line and continue until the end of the line. Comments must be separated from other tokens by white space characters.[7]Unless they appear inside of a string, then they are number ( # ) sign literals.
  • List members are denoted by a leading hyphen ( - ) with one member per line, or enclosed in square brackets ( [ ] ) and separated by comma space ( ,   ).
  • Associative arrays are represented using the colon space ( :   ) in the form key: value, either one per line or enclosed in curly braces ( {   } ) and separated by comma space ( ,   ).
    • An associative array key may be prefixed with a question mark ( ? ) to allow for liberal multi-word keys to be represented unambiguously.
  • Strings (scalars) are ordinarily unquoted, but may be enclosed in double-quotes ( ” ), or single-quotes ( ‘ ).
    • Within double-quotes, special characters may be represented with C-style escape sequences starting with a backslash ( \ ). According to the documentation the only octal escape supported is .
  • Block scalars are delimited with indentation with optional modifiers to preserve ( | ) or fold ( > ) newlines.
  • Multiple documents within a single stream are separated by three hyphens ( --- ).
    • three periods ( ... ) optionally end a file within a stream.
  • Repeated nodes are initially denoted by an ampersand ( & ) and thereafter referenced with an asterisk ( * ).
  • Nodes may be labeled with a type or tag using the exclamation point ( !! ) followed by a string, which can be expanded into a URI.
  • YAML documents in a stream may be preceded by directives composed of a percent sign ( % ) followed by a name and space delimited parameters. Two directives are defined in YAML 1.1:
    • The %YAML directive is used to identify the version of YAML in a given document.
    • The %TAG directive is used as a shortcut for URI prefixes. These shortcuts may then be used in node type tags.

YAML requires that colons and commas used as list separators be followed by a space so that scalar values containing embedded punctuation (such as 5,280 or http://www.wikipedia.org) can generally be represented without needing to be enclosed in quotes.

Two additional sigil characters are reserved in YAML for possible future standardisation: the at sign ( @ ) and accent grave ( ` ).