Skip to main content

Command Palette

Search for a command to run...

YAML Ain’t Markup Language for You!

Published
4 min read
YAML Ain’t Markup Language for You!

Hey folks!!

Let me introduce YAML — which originally stood for “Yet Another Markup Language”, but today it’s proudly known as “YAML Ain’t Markup Language.”

I know… we developers love making things sound buzzy 😄

But hey, why are we even talking about it today?
Because YAML is everywhere! From Docker and Kubernetes to GitHub Actions, CI/CD pipelines, and even AI automation configs — YAML silently powers a lot of the tools we use daily.

Pretty cool, right?


Why YAML?

That’s a fair question — after all, we already have JSON and XML.
So why introduce yet another format?

Let’s break it down:

FeatureYAMLJSONXML
ReadabilityHuman-friendly and cleanMachine-friendlyVerbose and cluttered
SyntaxUses indentationUses curly braces {}Uses opening/closing tags
CommentsSupported with #Not supportedSupported
Data TypesFlexible (lists, maps, scalars)LimitedExtensive but heavy
Use CaseConfiguration filesData exchangeDocument markup

In short — YAML focuses on humans, not machines.
It’s simple, concise, and much easier on the eyes compared to its cousins.
No endless braces or closing tags — just indentation. That’s it!

Note: YAML files usually have .yaml or .yml extensions. Both works fine.

Let’s See YAML in Action

Let’s jump straight into practice!
Here’s a simple Docker Compose file that sets up a PostgreSQL service:

version: '3.8' # version here is for `configuration`, not YAML itself!

# This is my Postgres service
services:
  db:
    image: postgres:15
    container_name: my_postgres_db
    restart: always
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: secret123
      POSTGRES_DB: sampledb
    ports:
      - "5432:5432"
    volumes:
      - db_data:/var/lib/postgresql/data

volumes:
  db_data:

Looks neat, right?
No braces, no tags — just clean indentation.

Breaking Down the Syntax

Key-Value Pairs

Everything in YAML revolves around keys and values.

POSTGRES_USER: admin

Here, POSTGRES_USER is assigned the value admin.

Lists

Lists start with a dash - followed by a space.

ports:
  - "5432:5432"

ports is a list containing one item.

Indentation

Indentation defines structure (like nesting in Python).

Tabs are not allowed — only spaces (usually 2 or 4).
Misalignment = broken YAML!

Comments

Use # to add comments.

# This is my Postgres service

Common Data Types

TypeExample
String"Omkar"
Integer / Float2, 8.5
Booleantrue, false, on, off, etc
Nullnull

In YAML, !! is used as a tag indicator to explicitly specify the data type of a value.

Dictionaries (Nested Structures)

You can nest dictionaries easily — that’s where YAML shines.

person:
  name: "Omkar Tavva"
  role: "Developer"
  skills:
    - Kotlin
    - Flutter
    - React

Here, person is a dictionary, and skills is a list inside it.
Simple and readable.

Multi-line Strings

Sometimes you need long text blocks — YAML has your back.

description: |
  YAML stands for "YAML Ain't Markup Language".
  It’s designed for simplicity and readability.

The difference between the two styles:

| → Preserves new lines

> → Joins lines into a single paragraph

Anchors & Aliases

YAML can reuse content using anchors (&) and aliases (*):

defaults: &defaults
  restart: always
  image: nginx:latest

service1:
  <<: *defaults
  container_name: web1

service2:
  <<: *defaults
  container_name: web2

This avoids duplication — perfect for repetitive configs!

Common Mistakes in YAML

Even though YAML looks simple, a few things can trip you up:

  • Using tabs instead of spaces

  • Inconsistent indentation

  • Missing colons or dashes

  • Quote confusion – quote strings with special characters (:, #, @)

Best Practices

If you’re writing YAML often, here are a few things to remember:

  • Keep indentation consistent throughout your file.

  • Use descriptive, meaningful keys.

  • Group related configurations together.

  • Add comments for clarity.

  • Validate YAML using tools like yamlchecker.com before deploying.


Wrapping It Up

YAML is that quiet hero working behind the scenes — simple, structured, and powerful.
From defining workflows to spinning up containers, YAML makes automation human-readable again.

So next time you open a .yml file, remember —
it’s not just configuration; it’s clean communication between you and your tools.

And now that you’ve met YAML properly, I’d say...YAML Ain’t Markup Language for You!

Thanks for reading till the end — and hey, if you didn’t get bored, that’s YAML magic right there!