YAML Multiline String Indentation – Fix Block Scalar Errors

Local only

Content after | or > must stay indented as part of the block scalar. A line that de-indents too early can end the scalar and leave invalid YAML after it.

36 chars · 3 lines

Waiting for input

Loading YAML parser…

YAML block scalar troubleshooting

How to fix YAML multiline string indentation

The preloaded literal block uses two spaces for its first content line and only one for the second. That second line leaves the scalar before a valid outer YAML structure begins, so the document cannot be parsed as intended. This tool is free to use. No account or payment is required.

Last updated

What you can do here

  • YAML 1.2 parser validation
  • Duplicate mapping key detection
  • Preloaded broken YAML example
  • Readable parser feedback
  • .yaml and .yml file import
  • Browser-local processing

Steps

  1. Locate the key followed by | or > and identify all lines that belong to its text value.
  2. Indent every intended content line consistently beyond the parent key.
  3. Validate again and review the resulting text semantics in the consuming application.

De-indentation ends a YAML block scalar

Literal and folded scalars use indentation to determine how much following text belongs to the value. When indentation returns to the parent level, the scalar is finished and YAML structure resumes.

Literal and folded scalars have different text behavior

The | marker preserves line breaks while > folds many line breaks into spaces. Fixing indentation restores valid YAML, but you should still choose the scalar style that matches the text your application expects.

Multiline YAML scalar indentation example

Both text lines need to remain indented beneath the message key.

Invalid YAML

message: |
  first line
 second line

Corrected YAML

message: |
  first line
  second line

Common questions

Frequently asked questions

What does | mean in YAML?

The literal block scalar marker | keeps line breaks in the multiline string while indentation determines which following lines belong to the value.

What does > mean in YAML?

The folded block scalar marker > combines many line breaks into spaces while still using indentation to delimit the scalar content.

Why did one line leave my multiline YAML value?

A line that de-indents to the parent level ends the block scalar, so the parser starts treating that text as YAML structure again.

Debugging a specific YAML issue? Browse YAML troubleshooting.