3 min read
YAML Multiline String Generator
Enter the text you want to store in YAML. This generator creates a block scalar you can paste into a YAML key-value pair.
description: | This is the first line. This is the second line. This is a new paragraph.
The output is generated locally in your browser. Review indentation and test the result with a YAML validator before using it in production.
How YAML multiline strings work
YAML block scalars let you write long text across multiple indented lines without escaping every line break. They are commonly used for descriptions, messages, configuration values and scripts.
Literal style (|) keeps line breaks in the text. Folded style (>) generally turns ordinary line breaks into spaces, while blank lines still separate paragraphs. The chomping marker controls the final newline: the default clips to one final newline, - strips it, and + keeps trailing blank lines.
Indentation matters in YAML. Content lines must be indented beneath the key, and the indentation indicator can help when the content begins with spaces. If your text includes unusual indentation or tabs, validate the generated YAML before using it.
Example
For a value that should preserve line breaks, use a literal block:
description: |
First line
Second lineFor prose where ordinary line breaks should be folded, use > instead:
description: >
This is a long sentence
that wraps onto another line.These examples illustrate the basic syntax. The exact resulting string depends on the block style, blank lines, indentation and chomping indicator.
Frequently asked questions
What is a YAML multiline string?
A YAML value written across multiple lines, often using a block scalar such as | or >.
What is the difference between | and >?
Literal style preserves line breaks; folded style folds most ordinary line breaks into spaces.
What do - and + mean?
They control trailing newline handling. - strips trailing newlines; + preserves them. With no marker, YAML uses clip behavior.
Why does indentation matter?
YAML uses indentation to identify structure and determine which lines belong to the scalar. Incorrect indentation can change the value or make the document invalid.
Can I use this output in a config file?
Yes, after reviewing the result and validating it in the context of your full YAML document.
Related tools: YAML Validator, YAML Formatter, YAML to JSON Converter, and JSON to YAML Converter.
Share this:
- Share on WhatsApp (Opens in new window) WhatsApp
- Share on LinkedIn (Opens in new window) LinkedIn
- Share on Facebook (Opens in new window) Facebook
- Share on X (Opens in new window) X
- Email a link to a friend (Opens in new window) Email
- Share on Pinterest (Opens in new window) Pinterest
- Share on Telegram (Opens in new window) Telegram
- Print (Opens in new window) Print