YAML Quickstart: Only things you need to get started
YAML is a data serialization language that is widely used for writing configuration files, making it a must-know language. Data serialization is the process of converting complex data objects into a byte stream that saves the object’s state in a form that is easy to store or transmit.

YAML was an acronym for “Yet Another Markup Language” but now it stands for “YAML Ain’t Markup Language” to emphasize more on its data-oriented features.
POPULARITY OF YAML
YAML is an alternative for other data serialization languages like JSON, XML, BSON, etc. One of the main reasons YAML is becoming more popular is that it has higher readability due to its clean and concise syntax, making it easier to work with.
YAML BASICS
A YAML file normally begins with three dashes and ends with three dots, however this is optional.
Key-value pairs are the foundation of all YAML documents. A colon separates key-value pairs.
---
version: 1.4
description: Sample file
...
YAML supports all the basic scalar data types like:
integer: 40
float: 40.5
string: Forty
boolean: True
Note: A Boolean value can be True/False or Yes/No or On/Off.
We can also declare null values using the keyword null or ~ symbol.
balance: null
balance: ~
YAML BUILDING BLOCKS
First and foremost, whitespace is an essential part of YAML formatting. Maps and lists are the two building blocks that you will frequently encounter in YAML files.
Indentations are used to define a map, also known as a dictionary, hash map, or object. All the key-value pairs at same indentation level belong to the same map.
Lists or arrays are defined using a single dash to list each individual list item.
user: Jake
age: 25
address:
state: CA
country: USA
movies:
- Interstellar
- Die Hard
- The Godfather
Maps and lists can also be defined in a single line using curly and square brackets respectively.
user: Jake
age: 25
address: {state: CA, country: USA}
movies: [Interstellar, Die Hard, The Godfather]
To appreciate the readability of YAML, this is how the same data looks in JSON format. One interesting thing to note is YAML is a superset of JSON, which means that any JSON is a valid YAML file.
{
"user": "Jake",
"age": 25,
"address": {
"state": "CA",
"country": "USA"
},
"movies": [
"Interstellar",
"Die Hard",
"The Godfather"
]
}
LITTLE MORE YAML
You can also define how YAML handles multi-line strings using block style indicators. Use the | symbol if you want to keep the newlines. Use the > sign to replace newlines with spaces.
review2: |
This will
all be on
separate linesreview1: >
This will
all be in
one line
Finally, you can write comments in a YAML file using # symbol. YAML only supports single-line comments.
# This a comment in YAML
CONCLUSION
We have covered all the fundamentals needed to get started with YAML. Now to wrap things up, let’s take a look at a docker-compose.yaml configuration file from one of my projects. Just try to grasp the general structure of the YAML file.

YAML is quickly gaining popularity and is extensively used to create configuration files. Knowing YAML is a must, especially for anyone with an interest in DevOps and Cloud Computing.