Definition

YAML (YAML Ain't Markup Language)

What is YAML (YAML Ain't Markup Language)?

YAML (YAML Ain't Markup Language) is a data serialization language used as the input format for diverse software applications.

An application user or administrator specifies data in a YAML file that the application then reads. For example, YAML files can define users or install software packages on servers.

The YAML acronym originally stood for "Yet Another Markup Language" when YAML debuted in May 2001. By the start of 2002, the language's creators had changed the acronym's meaning to the recursive "YAML Ain't Markup Language" to reflect that, while YAML's structure resembles a markup language, it is not used for document markup.

Applications that use YAML include the configuration management tool Ansible, the container orchestrator Kubernetes and the orchestration engine OpenStack Heat. The programming language Python relies on the YAML syntax, but most programming languages can interpret it.

Key-value pairs in YAML

In YAML, Key-value pairs are defined and separated with a colon. Keys are unique identifiers to which one or multiple values can be assigned.

Key-value pairs are specified in lists, where one item in the list can be followed by a complete configuration that should be created for that item. For example, items might be parts of a configuration that need to be defined on a computer system or entries to import into a database.

YAML syntax

YAML is relatively easy to write. Simple YAML files do not use data formatting items, such as braces and square brackets; instead, most relations among items are defined using indentation.

The syntax of a YAML file is rather strict and relies on indentation. In YAML, each child item of a given parent item is indented by two spaces. Dashes can indicate items in a list.

The image displays several lines of code that demonstrate the use of key-value pairs, indentation and dashes in YAML.
This code snippet demonstrates the use of key-value pairs, indentation and dashes in YAML.

Blocks do not span multiple lines in the YAML format. YAML users have several options for formatting the data presented by a YAML file, such as mappings, sequences and scalars.

YAML vs. JSON

YAML is frequently an alternative to the data interchange format JSON (JavaScript Object Notation). Both are alternatives to XML (Extensible Markup Language). Both YAML and JSON are intended to be human-readable formats, although JSON more easily transfers from one programming language environment to another.

This was last updated in January 2023

Continue Reading About YAML (YAML Ain't Markup Language)

Dig Deeper on Systems automation and orchestration