"All Mapping Items Must Start at the Same Column" — Fixing the YAML Indentation Error

By · Published

That is the literal message the yaml parser throws, word for word. It means two keys that should be siblings in the same mapping start at different columns:

name: Ada
role: engineer
 team: platform      # <- indented one extra space, breaks the mapping

# All mapping items must start at the same column

team sits one space further in than name and role, so the parser can't tell whether it still belongs to the same mapping or opens something nested. JSON has a closing brace to end a block. YAML doesn't, and indentation is the whole signal. One stray space changes what the document means.

The usual causes

Advertisement

Fixed version

name: Ada
role: engineer
team: platform

Finding it fast

A one-space difference is hard to see by eye. Paste the YAML into the converter here and the error message gives you the line number the parser failed on. That number comes from the parser's own linePos, not a guess, so you can jump straight to the misaligned key instead of scanning the whole file. For the tabs-vs-spaces variant, turn on "show whitespace" or "render tabs" in your editor and you'll catch it before it gets this far.

Advertisement

Try the YAML ↔ JSON Converter →