YAML support
YAML.sh accepts the syntax below. The parser boundaries section names nearby forms it rejects.
Collections
- Nested block mappings using space indentation.
- Block sequences in indented and indentationless styles.
- Single-line flow sequences and mappings.
- Multiline flow sequences and mappings.
- Expanded and flow mappings inside sequences.
- Empty flow mappings (
{}) and sequences ([]). - Duplicate mapping-key rejection.
- Scalar explicit keys using
? keyfollowed by: value.
Scalars
- Plain, single-quoted, and double-quoted scalars.
- YAML double-quoted escapes, including
\x,\u, and\Ucode points. - Multiline plain and quoted scalar folding.
- Literal (
|) and folded (>) block scalars. - Strip (
-), clip, and keep (+) chomping behavior for common block scalars. - Explicit block-scalar indentation indicators from 1 through 9.
- Lexical recognition of strings, nulls, booleans, binary/octal/decimal/hexadecimal integers, floats, and timestamps.
Scalar values print as text in default output. Recognized types also drive numeric evaluation, JSON output, patches, schema validation, and the type operator.
Anchors, aliases, and merges
- Backward scalar, mapping, and sequence aliases.
- Anchors scoped to one document.
- Anchor redefinition for later aliases.
- Merge keys from one mapping alias.
- Inline merge sequences such as
<<: [*first, *second]. - Block merge sequences.
- Flow mapping merge sources.
- Explicit-key precedence over merged keys.
- First-source precedence within merge sequences.
- Undefined, forward, recursive, and non-mapping merge-source validation.
Aliases retain node identity internally. JSON and normal value output resolve aliases to their target content.
Tags and directives
%YAMLdirectives, with duplicates and malformed versions rejected.%TAGdirectives and handle expansion.- Standard
!!tags. - Verbatim tags such as
!<tag:example.com,2026:widget>. - Local and application tags on scalar and collection nodes.
--taginspection using the expanded tag value.
YAML version directives are validated but do not switch between complete YAML 1.1 and YAML 1.2 schema resolvers. Application tags are metadata; YAML.sh does not run constructors or create language-specific objects.
Streams and source details
- Blank lines and comments.
- Inline comments outside quoted and flow content.
- LF and CRLF input.
- Multiple documents using
---and.... - Empty explicit documents represented as null.
- Exact source lines and columns for block and multiline flow values and keys; generated nodes report 0.
- Anchor, alias, tag, scalar/collection style, and value/key head, line, and foot comments available to queries and setters.
Parser boundaries
- Aliases must refer to an earlier anchor in the same document.
- Recursive alias graphs are rejected.
- Anchor names may contain Unicode and punctuation except whitespace and flow delimiters.
- Collection-valued mapping keys are rejected. Explicit scalar keys are supported.
- Tags and anchors before scalar keys are accepted, but mapping keys remain text in the graph.
- Full YAML 1.1/1.2 schema resolution and application-specific construction are not implemented.
Malformed directives, reserved indicators, malformed escapes, indentation errors, invalid aliases, invalid merge sources, duplicate keys, and unsupported complex keys fail before producing a document graph.
Expression behavior belongs in the query reference; emitted YAML belongs in output and metadata; edit preservation belongs in documents and file edits.