What is a YAML File? — The Config Language Every Developer Must Know
YAML is not a markup language — it's the universal glue that holds modern software config together, and it's simpler than you think.
Config files are everywhere in modern dev — Docker, Kubernetes, GitHub Actions, VS Code — and most of them speak one language: YAML. Here’s everything you need to read, write, and debug it confidently.
🤔 What is YAML? — The Name is a Joke
YAML stands for “YAML Ain’t Markup Language” — a recursive acronym (geek humour at its finest). It was originally called Yet Another Markup Language, but the community renamed it to emphasise that it’s about data, not document markup like HTML or XML.
At its core, YAML is a human-readable data serialisation format — a way to express structured data (key-value pairs, lists, nested objects) in plain text.
First released in 2001, it’s now the de-facto standard for:
- Application configuration (
.yaml/.yml) - Infrastructure-as-code (Kubernetes, Ansible, Terraform)
- CI/CD pipelines (GitHub Actions, GitLab CI)
- Data exchange between services
🧱 Core Syntax — The 3 Building Blocks
YAML has three fundamental data structures. Everything else is built from these.
1. Mappings (Key-Value Pairs)
1
2
3
4
name: Yuxuan
age: 22
university: NTU
is_student: true
- Separator: colon + space (
:) - Values can be strings, numbers, booleans, or
null - No quotes needed for simple strings (but use them if the value contains special chars)
2. Sequences (Lists)
1
2
3
4
5
skills:
- Python
- PyTorch
- Signal Processing
- YAML # meta
- Each list item starts with
-(dash + space) - Indentation groups items under a key
3. Nested Structures
1
2
3
4
5
6
7
8
project:
title: Sparse-View CT Reconstruction
supervisor: Prof. Jiang Xudong
deadlines:
- name: Final Report
date: 2026-04-30
- name: Oral Presentation
date: 2026-05-12
Nesting is done purely with consistent indentation (2 or 4 spaces — never tabs).
💡 One-Sentence Intuition: YAML is just Python-dict-style data written in a file — indentation = nesting, colon = assignment, dash = list item.
📦 Data Types at a Glance
| Type | Example | Notes |
|---|---|---|
| String | name: Yuxuan | No quotes needed unless special chars |
| Quoted string | msg: "Hello, World!" | Use " or ' |
| Integer | port: 8080 | Plain number |
| Float | lr: 0.001 | Learning rate, etc. |
| Boolean | debug: true | true/false, yes/no |
| Null | value: null | Or ~ |
| Multiline string | \| or > block scalars | See below |
Multiline Strings: | vs >
1
2
3
4
5
6
7
8
9
# Literal block (|) — preserves newlines
script: |
echo "Training started"
python train.py --epochs 100
# Folded block (>) — folds newlines into spaces
description: >
This is a very long description
that wraps across multiple lines.
Use
|for shell scripts and code. Use>for prose paragraphs.
🔄 How YAML Fits Into a Project — The Flow
flowchart LR
A([Developer writes config.yaml]) --> B[App / Tool reads YAML]
B --> C{Parse}
C -->|dict / object| D[Python / JS / Go code]
C -->|validation error| E[Fix syntax]
D --> F([Runtime behaviour])
style A fill:#4A90D9,color:#fff
style B fill:#5BA85A,color:#fff
style D fill:#9B6EBD,color:#fff
style F fill:#E8A838,color:#000
style E fill:#D9534F,color:#fff
The YAML file acts as the interface between the developer’s intent and the tool’s behaviour — without recompiling any code.
⚙️ Real-World Examples You’ll See Every Day
Docker Compose
1
2
3
4
5
6
7
8
9
10
version: "3.9"
services:
web:
image: nginx:alpine
ports:
- "8080:80"
db:
image: postgres:15
environment:
POSTGRES_PASSWORD: secret
GitHub Actions CI/CD
1
2
3
4
5
6
7
8
9
10
11
12
13
name: Run Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install deps
run: pip install -r requirements.txt
- name: Run tests
run: pytest
Kubernetes Deployment
1
2
3
4
5
6
7
8
9
10
11
12
13
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
template:
spec:
containers:
- name: app
image: my-app:latest
ports:
- containerPort: 5000
All three tools — Docker, GitHub Actions, Kubernetes — use YAML for the same reason: it’s readable by humans AND machines with zero special tooling.
⚔️ YAML vs JSON vs TOML — Quick Comparison
| Feature | YAML | JSON | TOML |
|---|---|---|---|
| Human readable | ✅ Best | ⚠️ OK | ✅ Great |
| Comments | ✅ # | ❌ None | ✅ # |
| Multiline strings | ✅ Native | ⚠️ \n escape | ✅ """ |
| Strict syntax | ❌ Indentation traps | ✅ Clear | ✅ Clear |
| Use case | Config, CI/CD, K8s | APIs, data exchange | App config (Rust, Python) |
| Parse errors | 😤 Cryptic | 😌 Clear | 😌 Clear |
YAML’s biggest trap: mixing tabs and spaces, or inconsistent indentation. Always configure your editor to use spaces only and show whitespace characters.
⚠️ Common YAML Gotchas
The Norway Problem:
country: NO— YAML parsesNOas booleanfalse! Always quote ambiguous strings:country: "NO".
Other traps:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# ❌ Dangerous: these are all parsed as booleans
enabled: yes # true
flag: off # false
country: NO # false (!)
# ✅ Safe: quote them
country: "NO"
flag: "off"
# ❌ Tabs cause parse errors — never use tabs
key:
value # This will break!
# ❌ Missing space after colon
key:value # Parsed as string "key:value", not a mapping!
# ✅ Always colon + space
key: value
Use yamllint (
pip install yamllint) or paste into yamlchecker.com to validate before committing.
🧠 One-Sentence Intuition
YAML is structured data written the way you’d naturally indent a to-do list — once you see the three primitives (key-value, list, nested), every config file becomes readable.
📌 Quick Reference Cheatsheet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# --- Mappings ---
key: value
number: 42
flag: true
nothing: null
# --- Lists ---
items:
- apple
- banana
# --- Nested ---
parent:
child: value
list:
- a
- b
# --- Multiline ---
code: |
line 1
line 2
# --- Comments ---
# This is a comment
# --- Multiple docs in one file ---
---
doc: one
---
doc: two
🎬 Watch & Learn — Video Resources
Learn YAML in 18 Minutes (TechWorld with Nana)
A fast, DevOps-focused crash course — syntax, real examples, Docker & K8s configs all in one go.
Complete YAML Course — Beginner to Advanced (KodeKloud)
Goes deeper into anchors, aliases, multi-document files, and schema validation. Great follow-up once you have the basics down.
Part of DevTools fundamentals series. Next up: Docker Compose deep-dive — spinning up multi-container apps with a single command.