A small yaml cheat sheet - Mon, Mar 28, 2022
A small yaml cheat sheet
Knowing the basic of Yaml
as a software engineer has got more important throughout the last years because of its widespread usage for deployment definitions and CI/CD configurations.
Since I always stumble above the same syntactically stumbling block, I decide to make a small cheat sheet with some Yaml basics and oddities (you might be surprised what is valid yaml):
# Mappings
key: "This is the value"
# Nested mappings
Chihuahua:
size: small
color: brown
Border Collie: {size: medium, color: black and white}
# Arrays / Collections / Lists (different syntaxes):
birds:
- Starling
- Sparrow
fish: [Catfish, Cod]
dogs:
-
Poodle
-
Beagle
dinosaurs: []
cats:
-
Ragdoll
-
Persian
# Collection of nested mappings
# The values in a list do not have to be the same type
animals:
- birds:
Starling: black
Sparrow: brown
- dogs:
Dalmatian: dotted
# Strings
my-normal-string: this is not a normal string
# Escape sequences need double quotes:
my-escaped-string: "this is not a normal string\n"
# Multi line with new lines:
first-quote: >
Tell me and I forget.
Teach me and I remember.
Involve me
and I learn
# Multi line without new lines:
second-quote: |
Tell me and I forget.
Teach me and I remember.
Involve me
and I learn
# Multi line without trailing spaces new lines (The "-" strips the last character):
third-quote: |-
Tell me and I forget.
Teach me and I remember.
Involve me
and I learn
# Comments:
# This is a full line comment
commented-key: "This is the value" # This is a comment too
Fell free to paste the content above in the yaml linter or the json converter . Both should produce valid output.