YAML (YAML Ain't Markup Language) is a human-readable data serialization standard commonly used for configuration files, data exchange, and storing structured data. It uses indentation and simple syntax to represent complex data structures in a clean, readable format.

Key Features

  • Human-readable: Easy to read and write by humans
  • Indentation-based: Uses spaces (not tabs) for structure
  • Data types: Supports strings, numbers, booleans, arrays, objects
  • Comments: Allows comments using # symbol
  • Multi-document: Can contain multiple documents in one file

YAML Syntax Examples

Basic Configuration File

# Application Configuration
app:
  name: "Lead With Skills Platform"
  version: "2.1.0"
  debug: true
  port: 3000

database:
  host: "localhost"
  port: 5432
  name: "leadwithskills_db"
  username: "admin"
  password: "secure_password"

features:
  - user_authentication
  - course_management
  - progress_tracking
  - mentorship_booking

social_media:
  twitter: "@leadwithskills"
  linkedin: "company/leadwithskills"
  github: "leadwithskills"
                    

Docker Compose Example

version: '3.8'

services:
  web:
    build: .
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - DATABASE_URL=postgresql://user:pass@db:5432/myapp
    depends_on:
      - db
      - redis

  db:
    image: postgres:13
    environment:
      POSTGRES_DB: myapp
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
    volumes:
      - postgres_data:/var/lib/postgresql/data

  redis:
    image: redis:6-alpine
    ports:
      - "6379:6379"

volumes:
  postgres_data:
                    

Common Use Cases

  • Configuration Files: Application settings, CI/CD pipelines
  • Docker Compose: Multi-container application definitions
  • Kubernetes: Container orchestration manifests
  • GitHub Actions: Workflow automation
  • Ansible: Infrastructure automation playbooks
  • OpenAPI: API documentation specifications

YAML vs Other Formats

YAML
Human-readable, indentation-based
JSON
Compact, widely supported
XML
Verbose, supports attributes