Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
YAML
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Syntax=== A cheat sheet and full specification are available at the official site.<ref>{{cite web |url=https://yaml.org/refcard.html |title=YAML{{nbsp}}1.1 Reference Card |website=YAML.org |access-date=2019-05-29 |archive-date=2019-04-14 |archive-url=https://web.archive.org/web/20190414205255/https://yaml.org/refcard.html |url-status=live }}</ref> The following is a synopsis of the basic elements. YAML accepts the entire Unicode character set, except for some [[control character]]s, and may be encoded in any one of [[UTF-8]], [[UTF-16]] or [[UTF-32]]. (Though UTF-32 is not mandatory, it is required for a parser to have [[JSON]] compatibility.)<ref>{{cite web|url=https://yaml.org/spec/1.2/spec.html#id2771184|title=YAML Ain't Markup Language (YAML) Version 1.2|website=YAML.org|access-date=2019-05-29|archive-date=2019-01-24|archive-url=https://web.archive.org/web/20190124222648/https://yaml.org/spec/1.2/spec.html#id2771184|url-status=live}}</ref> * [[Whitespace (computer science)|Whitespace]] [[Indent style|indentation]] is used for denoting structure; however, [[tab character]]s are not allowed as part of that indentation.<ref name="YAML v1.2.2">{{cite web|url=https://yaml.org/spec/1.2.2/#indentation-spaces|title=YAML specification v1.2.2 Section 6.1. Indentation Spaces|access-date=2023-03-12|archive-date=2023-03-12|archive-url=https://web.archive.org/web/20230312144139/https://yaml.org/spec/1.2.2/#indentation-spaces|url-status=live}}</ref> * [[Comment (computer programming)|Comments]] begin with the [[number sign]] ({{code|#}}), can start anywhere on a line and continue until the end of the line. Comments must be separated from other tokens by whitespace characters.<ref>{{cite web|url=https://yaml.org/spec/1.2/spec.html#id2780069|title=YAML Ain't Markup Language (YAML) Version 1.2|website=YAML.org|access-date=2019-05-29|archive-date=2019-01-24|archive-url=https://web.archive.org/web/20190124222648/https://yaml.org/spec/1.2/spec.html#id2780069|url-status=live}}</ref> If {{code|#}} characters appear inside of a string, then they are number sign ({{code|#}}) literals. * List members are denoted by a leading [[Hyphen-minus|hyphen]] ({{code|-}}) with one member per line. ** A list can also be specified by enclosing text in [[square brackets]] ({{code|[...]}}) with each entry separated by a [[Comma (punctuation)|comma]]. * An [[associative array]] entry is represented using [[colon (punctuation)|colon]] [[Space (punctuation)|space]] in the form ''key: value'' with one entry per line. YAML requires the colon be followed by a space so that url-style strings like {{code|http://www.wikipedia.org}} can be represented without needing to be enclosed in quotes. ** A [[question mark]] can be used in front of a key, in the form "?key: value" to allow the key to contain leading dashes, square brackets, etc., without quotes. ** An associative array can also be specified by text enclosed in [[curly braces]] ({{code|{...} }}), with keys separated from values by colon and the entries separated by commas (spaces are not required to retain compatibility with JSON). * [[String (computer science)|String]]s (one type of scalar in YAML) are ordinarily unquoted, but may be enclosed in [[double quote|double-quotes]] ({{code|"}}), or [[single quote|single-quotes]] ({{code|'}}). ** Within double-quotes, special characters may be represented with [[C (programming language)|C-style]] escape sequences starting with a [[backslash]] ({{code|\}}). According to the documentation the only octal escape supported is {{code|\0}}. ** Within single quotes the only supported escape sequence is a doubled single quote ({{code|''}}) denoting the single quote itself as in {{code|'don''t'}}. * Block scalars are delimited with [[Indent style|indentation]] with optional modifiers to preserve (<code>|</code>) or fold ({{code|>}}) newlines. * Multiple documents within a single stream are separated by three [[hyphens]] ({{code|---}}). ** Three [[Full stop|periods]] ({{code|...}}) optionally end a document within a stream. * Repeated nodes are initially denoted by an [[ampersand]] ({{code|&}}) and thereafter referenced with an [[asterisk]] ({{code|*}}). * Nodes may be labeled with a type or tag using a double [[exclamation mark]] ({{code|!!}}) 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]] ({{code|%}}) followed by a name and space-delimited parameters. Two directives are defined in YAML 1.1: ** The %YAML directive is used for identifying 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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)