YAML is a data definition language that uses whitespace to indicate hierarchy, making files easy for humans to read. It is widely used for configuration files, workflow files and as a more readable alternative to JSON.

How it works

YAML defines data using key-value pairs, lists and nested structures. Whitespace (spaces or tabs) determines indentation, and most importantly: unlike JSON, YAML lets you use as many spaces as you want, since indentation defines the structure.

Practical example

A YAML file can describe a server configuration:

YAML
servidor:
  hostname: my-server
  port: 8080
  ambientes:
    - desenvolvimento
    - producao

This is more readable than the equivalent in JSON, where parentheses and braces indicate the structure.

What it is used for

YAML is used in: configuration files (docker-compose.yml, .gitlab-ci.yml), workflow definitions, AI model descriptions, system configuration files and metadata files.

  • JSON: alternative data format
  • XML: markup language
  • docker-compose: tool that uses YAML

How to test today

Create a simple .yaml file with three nested keys and validate it with an online tool, such as the YAML Validator.

Frequently asked questions

  • Is YAML a markup language? Actually, it is a data definition language, not a markup language. It is used for data structuring,
  • Is YAML better than JSON? It depends. YAML is more readable, but JSON is safer for data exchange between systems.
  • Where is YAML most used? In configuration files, such as docker-compose.yml, .gitlab-ci.yml and workflow definition files.