DevFormat
Back to Guides

What is YAML? A Guide for DevOps & Developers

YAML is arguably the most human-readable data serialization format. It's the standard for configuration in modern DevOps tools like Kubernetes, Docker, and GitHub Actions.

Introduction

YAML (YAML Ain't Markup Language) is a data serialization standard for all programming languages. It is designed to be human-friendly and works well with modern programming languages for common everyday tasks.

YAML is a superset of JSON, meaning any valid JSON file is effectively a valid YAML file! However, YAML is usually used for its cleaner, indentation-based syntax.

Why YAML?

  • Readability: No brackets, quotes are often optional. It looks like a clean list or outline.
  • Comments: Unlike standard JSON, YAML supports comments (`#`), making it perfect for configuration files where you need to explain settings.
  • Complex Structures: Supports anchors and aliases to reuse data chunks (DRY principle).

YAML Syntax

Indentation is critical in YAML. You must use spaces (usually 2), not tabs.

Key Concepts

  • Key-Value Pairs: `key: value`
  • Arrays/Lists: Denoted by a hyphen `- item`
  • Dictionaries/Maps: Nested indentation

Example

config.yaml
# Person Configuration
name: John Doe
age: 30
isDeveloper: true

# List of skills
skills:
  - JavaScript
  - Python
  - Docker

# Nested Address Object
address:
  street: 123 Tech Lane
  city: Silicon Valley

# Multi-line string (preserves newlines)
bio: |
  John loves coding.
  He also enjoys hiking.

Where is YAML used?

Kubernetes: Heavily relies on YAML manifests to define deployments, services, and pods.
CI/CD Pipelines: GitHub Actions, GitLab CI, and Azure DevOps all use YAML for pipeline definitions.
Configuration: Tools like Home Assistant, Ansible, and Prometheus use YAML.

YAML vs JSON

Use YAML when human readability is paramount and you need comments (e.g., config files). Use JSON for machine-to-machine communication (APIs) where parsing speed and simplicity are more important. Read full comparison.

Tools for YAML