Internet-Draft YAML Media Types April 2022
Polli, et al. Expires 3 October 2022 [Page]
Intended Status:
R. Polli
Digital Transformation Department, Italian Government
E. Wilde
E. Aro

YAML Media Types


This document registers the application/yaml media type and the +yaml structured syntax suffix on the IANA Media Types registry.

Note to Readers

RFC EDITOR: please remove this section before publication

Discussion of this draft takes place on the HTTP APIs working group mailing list (, which is archived at

The source code and issues list for this draft can be found at

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 3 October 2022.

1. Introduction

YAML [YAML] is a data serialization format that is widely used on the Internet, including in the API sector (e.g. see [oas]) but the relevant media type and structured syntax suffix are not registered by IANA.

To increase interoperability when exchanging YAML data and leverage content negotiation mechanisms when exchanging YAML resources, this specification registers the application/yaml media type and the +yaml structured syntax suffix.

Moreover, it provides security considerations and interoperability considerations related to [YAML], including its relation with [JSON].

1.1. Notational Conventions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. These words may also appear in this document in lower case as plain English words, absent their normative meanings.

This document uses the Augmented BNF defined in [RFC5234] and updated by [RFC7405].

The terms "content", "content negotiation", "resource", and "user agent" in this document are to be interpreted as in [SEMANTICS].

2. Media Type registrations

This section describes the information required to register the above media types according to [MEDIATYPE]

2.1. Media Type application/yaml

The following information serves as the registration form for the application/yaml media type.

Type name:


Subtype name:


Required parameters:


Optional parameters:

None; unrecognized parameters should be ignored

Encoding considerations:


Security considerations:

see Section 4 of this document

Interoperability considerations:

see Section 3 of this document

Published specification:

this document

Applications that use this media type:


Fragment identifier considerations:


Additional information:

  • Deprecated alias names for this type: application/x-yaml, text/yaml, text/x-yaml
  • Magic number(s) n/a
  • File extension(s): yaml, yml
  • Macintosh file type code(s): n/a
Person and email address to contact for further information:

See Authors' Addresses section.

Intended usage:


Restrictions on usage:



See Authors' Addresses section.

Change controller:


2.2. The +yaml Structured Syntax Suffix

The suffix +yaml MAY be used with any media type whose representation follows that established for application/yaml. The media type structured syntax suffix registration form follows. See [MEDIATYPE] for definitions of each of the registration form headings.


YAML Ain't Markup LanguageML (YAML)





Encoding considerations:

see Section 2.1

Fragment identifier considerations:

The syntax and semantics of fragment identifiers specified for +yaml SHOULD be as specified for Section 2.1 The syntax and semantics for fragment identifiers for a specific xxx/yyy+yaml SHOULD be processed as follows:

  1. For cases defined in +yaml, where the fragment identifier resolves per the +yaml rules, then process as specified in +yaml.
  2. For cases defined in +yaml, where the fragment identifier does not resolve per the +yaml rules, then process as specified in xxx/yyy+yaml.
  3. For cases not defined in +yaml, then process as specified in xxx/yyy+yaml.
Interoperability considerations:

See Section 2.1

Security considerations:

See Section 2.1


See Authors' Addresses section.


See Authors' Addresses section

Change controller:


3. Interoperability Considerations

3.1. YAML is an Evolving Language

YAML is an evolving language and, in time, some features have been added, and others removed.

While this document is based on a given YAML version [YAML], media types registration does not imply a specific version. This allows content negotiation of version-independent YAML resources.

Implementers concerned about features related to a specific YAML version can specify it in the documents using the %YAML directive (see Section 6.8.1 of [YAML]).

3.2. YAML and JSON

When using flow collection styles (see Section 7.4 of [YAML]) a YAML document could look like JSON [JSON], thus similar interoperability considerations apply.

When using YAML as a more efficient format to serialize information intented to be consumed as JSON, information can be discarded: this includes comments (see Section of [YAML]) and alias nodes (see Section 7.1 of [YAML]), that do not have a JSON counterpart.

# This comment will be lost
# when serializing in JSON.
  type: string
  maxLength: &text_limit 64

  type: string
  maxLength: *text_limit  # Replaced by the value 64.
Figure 1: JSON replaces alias nodes with static values.

Implementers need to ensure that relevant information will not be lost during the processing. For example, they might consider acceptable that alias nodes are replaced by static values.

In some cases an implementer may want to define a list of allowed YAML features, taking into account that the following ones might have interoperability issues with JSON:

  • non UTF-8 encoding, since YAML supports UTF-16 and UTF-32 in addition to UTF-8;
  • mapping keys that are not strings;
  • circular references represented using anchor (see Section 4.2 and Figure 3);
  • .inf and .nan float values, since JSON does not support them;
  • non-JSON types, including the ones associated with tags like !!timestamp that were included in the default schema of older YAML versions;
  • tags in general, and specifically the ones that do not map to JSON types like custom and local tags such as !!python/object and !mytag (see Section 2.4 of [YAML]);
  2020-01-01: a timestamp
  [0, 1]: a sequence
  ? {k: v}
  : a map
non-json-value: 2020-01-01
Figure 2: Example of mapping keys not supported in JSON

4. Security Considerations

Security requirements for both media type and media type suffix registrations are discussed in Section 4.6 of [MEDIATYPE].

4.1. Arbitrary Code Execution

Care should be used when using YAML tags, because their resolution might trigger unexpected code execution.

Code execution in deserializers should be disabled by default, and only be enabled explicitly. In those cases, the implementation should ensure - for example, via specific functions - that the code execution results in strictly bounded time/memory limits.

Many implementations provide safe deserializers addressing these issues.

4.2. Resource Exhaustion

YAML documents are rooted, connected, directed graphs and can contain reference cycles, so they can't be treated as simple trees (see Section 3.2.1 of [YAML]). An implementation that attempts to do that can infinite-loop at some point (e.g. when trying to serialize a YAML document in JSON).

Even if a document is not cyclic, treating it as a simple tree could lead to improper behaviors (such as the "billion laughs" problem).

x1: &a1 ["a", "a"]
x2: &a2 [*a1, *a1]
x3: &a3 [*a2, *a2]
Figure 4: A billion laughs document

This can be addressed using processors limiting the anchor recursion depth and validating the input before processing it; even in these cases it is important to carefully test the implementation you are going to use. The same considerations apply when serializing a YAML representation graph in a format that does not support reference cycles (see Section 3.2).

5. IANA Considerations

This specification defines the following new Internet media types [MEDIATYPE].

IANA has updated the "Media Types" registry at with the registration information provided below.

Table 1
Media Type Section
application/yaml Section 2.1 of this document

IANA has updated the "Structured Syntax Suffixes" registry at with the registration information provided below.

Table 2
Suffix Section
+yaml Section 2.2 of this document

6. Normative References

Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, , <>.
Freed, N., Klensin, J., and T. Hansen, "Media Type Specifications and Registration Procedures", BCP 13, RFC 6838, DOI 10.17487/RFC6838, , <>.
Darrel Miller, Jeremy Whitlock, Marsh Gardiner, Mike Ralphson, Ron Ratovsky, and Uri Sarid, "OpenAPI Specification 3.0.0", .
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <>.
Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/RFC5234, , <>.
Kyzivat, P., "Case-Sensitive String Support in ABNF", RFC 7405, DOI 10.17487/RFC7405, , <>.
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <>.
Fielding, R. T., Nottingham, M., and J. Reschke, "HTTP Semantics", Work in Progress, Internet-Draft, draft-ietf-httpbis-semantics-19, , <>.
Oren Ben-Kiki, Clark Evans, and Ingy dot Net, "YAML Ain't Markup Language Version 1.2", , <>.

Appendix A. Acknowledgements

Thanks to Erik Wilde and David Biesack for being the initial contributors of this specification, and to Darrel Miller and Rich Salz for their support during the adoption phase.

In addition to the people above, this document owes a lot to the extensive discussion inside and outside the HTTPAPI workgroup. The following contributors have helped improve this specification by opening pull requests, reporting bugs, asking smart questions, drafting or reviewing text, and evaluating open issues:

Tina (tinita) Mueller, Ben Hutton, Manu Sporny and Jason Desrosiers.


Q: Why this document?

After all these years, we still lack a proper media-type for YAML. This has some security implications too (eg. wrt on identifying parsers or treat downloads)

Change Log


Authors' Addresses

Roberto Polli
Digital Transformation Department, Italian Government
Erik Wilde
Eemeli Aro