Keyboard shortcuts

Press ← or β†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

multi-line strings

There are 9 (or 63*, depending how you count) different ways to write multi-line strings in YAML.

  • Use > most of the time: interior line breaks are stripped out, although you get one at the end:

      key: >
      Your long
      string here.
    
  • Use | if you want those linebreaks to be preserved as \n (for instance, embedded markdown with paragraphs):

      key: |
      ### Heading
    
      * Bullet
      * Points
    
  • Use >- or |- instead if you don’t want a linebreak appended at the end.

  • Use β€œβ€¦β€ if you need to split lines in the middle of words or want to literally type linebreaks as \n:

     key: "Hello\
     World!\n\nGet on it."