YAML Quickstart: Only things you need to get started

Photo by Ferenc Almasi on Unsplash

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.

Data Serialization and Deserialization [Source]

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.


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.


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: ~


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
state: CA
country: USA
- 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": [
"Die Hard",
"The Godfather"


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 lines
review1: >
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


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.

A docker compose configuration file [Source]

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.




Learning & Exploring …

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Front End Development with Gulp, Twig and SCSS — HTML Pages

Gulp, Twig and SCSS, a HTML front-end project.

How to upgrade Golang Compiler from version 1.13.5 to version 1.17.1

Replacing a computer component is just like replacing a Go-Compiler

Little Scheduling Features at canUmeet you wouldn’t want to miss.

Underestimation is Underestimated



Top 7 Programming languages to learn in 2019 to get a good Job.

Using Private Methods in Java Interfaces

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sanskar Sharma

Sanskar Sharma

Learning & Exploring …

More from Medium

Kubernetes Terminologies You Should Know!

The multiplier problem of Open Source

What is Devops?

5 Must-Have Google Chrome Extensions for Developers