YAML Cheat Sheet

Master YAML with our comprehensive cheat sheet. Explore essential syntax and best practices for configuration and data serialization. Perfect for developers.

Basic

Comments
# This is a comment
Scalar Types
string: "Hello, World"
integer: 123
float: 3.14
boolean: true
Inheritance
base: &default
  adapter: postgres
  host: localhost

development:
  <<: *default
  database: dev_db
Variables
name: &name Example
person:
  name: *name
Multiline strings
key: |
  This is a
  multiline string.
Folded strings
key: >
  This is a
  folded string.
Two Documents
---
key: value
---
another_key: another_value

YAML Collections

UnorderedSets
set:
  ? item1
  ? item2
  ? item3
Ordered Mappings
ordered_map:
  key1: value1
  key2: value2
Mapping to Sequences
mapping_to_sequences:
  key1:
    - item1
    - item2
  key2:
    - item3
    - item4
Sequence of Mappings
sequence_of_mappings:
  - key1: value1
    key2: value2
  - key3: value3
    key4: value4
Mapping
mapping:
  key1: value1
  key2: value2
Mapping of Mappings
mapping_of_mappings:
  parent1:
    child1: value1
    child2: value2
  parent2:
    child3: value3
    child4: value4

Shortcut Keys