In partnership with

YAML, originally known as Yet Another Markup Language, was later on renamed YAML Ain't Markup Language.

Do you need to know that?

No.

But I need to tell you that.

Anyways, it’s used to configure many popular tools like Docker Compose and Kubernetes.

And unlike JSON or XML, which use brackets and acorn for formatting, YAML uses space indentation.

Scalars (Data Types)

To get started, create a .yml or .yaml file.

The point of a config file is to create key pair values.

So let’s do that.

This creates a key where the value is a string.

anime: frieren

You can also wrap it with single or double quotes to make it explicit.

You can also create other data types (which is called scalars in YAML):

Just like what you do in other programming languages.

Cool.

But how do you create more complex data types like arrays or objects?

Mapping (Object)

To create an object, which is called mapping, use a colon and spaces (usually two) for indentation.

This creates an object with three properties: air date, studio, and season.

JSON version of the YAML code

Sequence (Array)

To create an array, use a dash and a space.

For example

Collection

Last but not least, you can nest everything.

For example, to create an array inside an object, combine a dash and a colon.

This whole block is called a collection.

YAML vs JSON

So, why do people use YAML over JSON (for configuration)?

This is an accurate depiction of YAML vs JSON:

This is what I mean:

The YAML version is just cleaner, more readable, and easier to write.

Which is not a surprise because it’s designed for human editing.

And you’ve just learnt everything you need to know to start writing YAML files.

Find out why 100K+ engineers read The Code twice a week

Staying behind on tech trends can be a career killer.

But let’s face it, no one has hours to spare every week trying to stay updated.

That’s why over 100,000 engineers at companies like Google, Meta, and Apple read The Code twice a week.

Here’s why it works:

  • No fluff, just signal – Learn the most important tech news delivered in just two short emails.

  • Supercharge your skills – Get access to top research papers and resources that give you an edge in the industry.

  • See the future first – Discover what’s next before it hits the mainstream, so you can lead, not follow.

Fee from Anime Coders

How did you like today's email?

Login or Subscribe to participate

Keep Reading

No posts found