📝 Tutorials

What is YAML? A Simple Explanation for Developers


YAML (YAML Ain’t Markup Language) is a human-readable data format used for configuration files. If you’ve used Docker Compose, Kubernetes, GitHub Actions, or almost any DevOps tool, you’ve written YAML.

name: Alice
age: 30
languages:
  - Python
  - JavaScript
  - Go

That’s it. No brackets, no quotes (usually), no commas. Just indentation and colons.

YAML vs. JSON

They represent the same data, but YAML is easier to read and write:

YAML:

server:
  host: localhost
  port: 8080
  debug: true
  allowed_origins:
    - http://localhost:3000
    - https://myapp.com

JSON equivalent:

{
  "server": {
    "host": "localhost",
    "port": 8080,
    "debug": true,
    "allowed_origins": [
      "http://localhost:3000",
      "https://myapp.com"
    ]
  }
}

YAML is more readable. JSON is more universal (every language can parse it natively).

Syntax basics

# Strings (quotes optional unless ambiguous)
name: Alice
message: "Hello: World"   # Quotes needed because of the colon

# Numbers and booleans
port: 8080
debug: true
ratio: 3.14

# Lists
fruits:
  - apple
  - banana
  - cherry

# Nested objects
database:
  host: localhost
  port: 5432
  credentials:
    user: admin
    password: secret

# Multi-line strings
description: |
  This is a multi-line
  string that preserves
  line breaks.

# Inline list and object
tags: [python, docker, devops]
point: {x: 1, y: 2}

Where you’ll see YAML

  • Docker Composedocker-compose.yml
  • Kubernetes — deployment manifests
  • GitHub Actions.github/workflows/*.yml
  • CI/CD — GitLab CI, CircleCI, Travis CI
  • Ansible — playbooks and inventory
  • Helm — chart values
  • Cloudformation / Terraform — infrastructure config

Common gotchas

Indentation must be spaces, not tabs. YAML doesn’t allow tabs. Use 2 spaces.

yes/no are booleans, not strings:

# ❌ This is boolean true, not the string "yes"
answer: yes

# ✅ Quote it if you mean the string
answer: "yes"

Colons in values need quotes:

# ❌ Breaks
message: Error: something failed

# ✅ Quote it
message: "Error: something failed"

For the full syntax reference, see the YAML cheat sheet.