DevOps Programming

YAML Key-Value Pairs

YAML documents primarily consist of key-value pairs, where keys and values are separated by a colon (:). It is essential to have a space after the colon to differentiate the key from the value.

Supported Data Types

  • Integer: Numbers without a decimal.
  • Floating Point Numbers: Numbers with a decimal.
  • Strings: Text data. Important: Quote strings that contain special characters such as colons (:), braces ({}), pipes (|), or brackets ([]).
  • Boolean: Values that are either true or false.
  • Dates: Should follow the ISO 8601 format.
  • Null Values: Represented as null or ~.

YAML Lists

YAML lists are denoted by a dash (-) and are indented.

  • Block Sequence: Each entry starts with a dash and a space (-).
  • Flow Sequence: Written as a comma-separated list within square brackets ([]).


  - Apple
  - Orange
  - Banana

numbers: [1, 2, 3, 4]

YAML Dictionary

YAML dictionaries group key-value pairs together under a single item.


  name: John Doe
  age: 30
  is_student: false

YAML Lists Containing Dictionaries

YAML allows lists to contain dictionaries, combining both structures.


  - name: Alice
    position: Developer
  - name: Bob
    position: Designer

YAML Lists Containing Dictionaries Containing Lists

You can nest lists within dictionaries inside a list, creating complex structures.


  - name: Engineering
      - Alice
      - Bob
  - name: Marketing
      - Charlie
      - Dana

YAML Pipe (|)

The pipe notation, also known as a literal block, preserves all new lines, indentation, and extra spaces as is.


description: |
  This is a multiline string.
  All new lines and spaces are preserved.

YAML Greater Than Sign (>)

The greater than sign notation, also known as a folded block, renders the text as a single line. New lines are replaced with a single space, while blank lines are converted to new line characters.


description: >
  This is a folded
  multiline string.
  New lines are replaced with spaces.

YAML Comments

Comments in YAML begin with the # sign. They are useful for adding notes or explanations within the document.


# This is a comment
name: John Doe  # This is an inline comment
age: 30

This guide outlines the structure and syntax of YAML, including key-value pairs, lists, dictionaries, and various notation styles for multiline text. Understanding these elements will help you effectively create and manage YAML documents.

Ali Imran
Over the past 20+ years, I have been working as a software engineer, architect, and programmer, creating, designing, and programming various applications. My main focus has always been to achieve business goals and transform business ideas into digital reality. I have successfully solved numerous business problems and increased productivity for small businesses as well as enterprise corporations through the solutions that I created. My strong technical background and ability to work effectively in team environments make me a valuable asset to any organization.

Leave a Reply