How to add comment in yaml

Adding Single-Line Comments in YAML

In YAML, single-line comments can be added using the hash symbol (#). Everything after the hash symbol on the same line is considered a comment and is ignored by the YAML parser. Here’s an example:

# This is a single-line comment in YAML
name: John Doe   # This comment is at the end of a line
age: 25

Adding Multiline Comments in YAML

Unlike some other languages, YAML doesn’t have a specific syntax for multiline comments. However, there are ways to add multiline comments in YAML files. The most straightforward method is to simply use multiple single-line comments, each starting with a hash symbol (#). Here’s an example:

# This is a multiline comment in YAML
# It spans across multiple lines
# Each line starts with a hash symbol (#)
name: Jane Doe
age: 28


comment: >
  This is a multiline comment in YAML
  using a block scalar. This text will be
  stored as a single string, but it won't
  be processed by the YAML parser.
name: Alice
age: 30