Skip to main content

YAML Comments

YAML supports single line comments.

# this is single line comment.

YAML does not support multi line comments. But, if you want to provide comments for multiple lines, you can use single line comments in this way:

# this is 
# a multiple
# line comment.

Features of Comments

  • A commented block is skipped during execution.
  • Comments help to add a description to specified block of code.
  • Comments must not appear inside scalars.
  • YAML does not provide any way to escape the hash symbol (#) a within multiline string, so there is no way to divide the comment from the raw value of the string.

For example, comments within a collection are made in this way:

key: #comment 1
- value 1
#comment 2
- value 2
#comment 3
- value line 3
note

Most IDEs support shortcuts for commenting blocks,

Check the support documentation of your preferred IDE.

Table of Contents