YAML (YAML Ain’t Markup Language) is a human-friendly data serialization standard, commonly used for configuration files and data exchange between languages with different data structures. Here’s a breakdown of its file structure:
A YAML file is composed of key-value pairs, lists, and nesting (indentation is critical):
key: value # Simple key-value pair
another_key: 123 # Numbers, booleans, and nulls are supported
Nesting is indicated by indentation (spaces only, not tabs):
parent:
child: value
Lists can be written using dashes:
fruits:
- apple
- banana
- cherry
You can nest dictionaries:
person:
name: Alice
age: 30
skills:
- Python
- YAML
Use # for comments:
# This is a comment
key: value # Inline comment
Strings can span multiple lines:
description: |
This is a
multi-line string.
Here’s a complete example:
server:
host: localhost
port: 8080
users:
- name: Alice
role: admin
- name: Bob
role: user
debug: true
-.key: value.#.Let me know if you want a deeper dive or examples for a specific use case!