Glossary · Cloud & DevOps

What is YAML?

Short answer

YAML (“YAML Ain’t Markup Language”) is a human-readable data format that uses indentation instead of brackets to express nested settings, lists and key-value pairs. It is the standard format for configuration in many tools, including GitHub Actions, Docker Compose, Kubernetes, OpenAPI specifications and Symfony.

An example

services:
  app:
    image: php:8.3-fpm
    environment:
      APP_ENV: production
    ports:
      - "8080:80"

Each level of indentation is a level of nesting; a leading - starts a list item. YAML is a superset of JSON, so valid JSON is also valid YAML.

Common pitfalls

  • Tabs are not allowed for indentation; use spaces consistently.
  • Unquoted values change type: no, yes and on may become booleans in older parsers, and 1.10 becomes the number 1.1. Quote version numbers and anything ambiguous.
  • Indentation mistakes silently move a setting to the wrong level. Validate files in CI with a linter.
  • Never load untrusted YAML with a parser that can create objects; use safe loading.

In PHP

The Symfony Yaml component (Yaml::parseFile()) is the standard parser, and the native yaml PECL extension is faster for large files. Laravel uses PHP arrays for its own configuration, but you will still meet YAML in Docker, CI and deployment files.

Published · Updated · By · All terms

Go deeper