Invalid YAML Block Scalar Header – Fix | and > Indicators

Local only

YAML block scalar headers only allow specific chomping and indentation indicators after | or >. Arbitrary characters such as x make the header invalid.

19 chars · 2 lines

Waiting for input

Loading YAML parser…

YAML block scalar header troubleshooting

How to fix an invalid YAML block scalar header

The sample writes |x after message. The pipe correctly starts a literal block scalar, but x is not a valid block scalar header indicator, so parsing fails before the multiline content is read. 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 | or > marker at the start of the failing block scalar.
  2. Remove unsupported characters or replace them with an intentional valid indicator.
  3. Keep the following content indented beneath the key and validate the document again.

Block scalar headers have a small, defined syntax

Literal | and folded > scalars may use chomping and indentation indicators, but the header is not a free-form place for labels or comments. Unexpected characters are parsed as invalid syntax.

Header fixes and content indentation are separate checks

Correcting the marker lets parsing continue, but the following text still needs valid scalar indentation. Validate the whole block rather than stopping after the header error disappears.

Invalid character after YAML literal block marker

Remove the unsupported x so the literal block begins with a valid | header.

Invalid YAML

message: |x
  hello

Corrected YAML

message: |
  hello

Common questions

Frequently asked questions

What does | mean in YAML?

It starts a literal block scalar whose line breaks are preserved while indentation determines which lines belong to the value.

What does > mean in YAML?

It starts a folded block scalar, which uses indentation for its extent and folds many internal line breaks into spaces.

Can characters follow | or > in YAML?

Only supported block scalar indicators should appear in the header. Arbitrary suffix characters make the scalar header invalid.

Debugging a specific YAML issue? Browse YAML troubleshooting.