← Back to Blog

YAML Multiline Strings: Block Scalars Explained

How to write multiline strings in YAML: literal block (|), folded block (>), chomping indicators, and when to use each.

Literal Block (|): Keep Newlines

description: |\n  Line 1\n  Line 2\n  Line 3\n# Result: 'Line 1\nLine 2\nLine 3\n'

Folded Block (>): Join Lines

description: >\n  This is a long\n  paragraph that will\n  be joined into one line.\n# Result: 'This is a long paragraph that will be joined into one line.\n'

Try It Free

Use our free online tool — 100% client-side, no data leaves your browser.

Open YAML Validator

Related Tools & Articles