YAML - Multiline Strings

This tutorial covers YAML tutorials,Multiline Strings with literal block and folded styles with indentation examples.

yaml multiline strings

As you know YAML document contains key and value pairs.

In yaml document, if value is larger to accommodated in single line,you can wrap string in multi lines.

There are two syntax ways we can represent multi line strings

  • literal block
  • folder block

literal styles with pipe operator

Multi line strings are stored using pipe character (|) .

important points about literal styles

  • The new line are preserved
  • Leading spaces or indentation are removed.
  • Strings can have with or without quotation marks

storing the new line using pipe character

string1: |

folded block styles with > character

The strings in multiple lines are enclosed as folded form using > character Important rules about folder syntax

  • Leading (beginning) indentation or spaces of a line are not considered
  • Trailing or end of line spaces are not preserved
  • new line are not preserved
  • new line are converted to spaces.
string1: >