Invalid YAML: inconsistent indentation

“Invalid YAML: inconsistent indentation” means sibling keys or list items are not aligned at the same column, or tabs are mixed with spaces. YAML treats indentation as structure, so one misaligned line breaks the whole document.

YAML expresses structure purely through indentation. Two sibling keys indented differently, or a single tab character, changes the document tree — and strict parsers stop with an indentation error.

The reported line is where the parser gave up, which is sometimes one line *after* the real problem.

Common causes

  • A tab character used for indentation — YAML forbids tabs; parsers count them differently than spaces.
  • Sibling keys indented by different amounts (2 spaces on one line, 4 on the next).
  • List items (-) not aligned with each other under the same parent key.
  • Copy-paste from a source with different indentation width, mixing 2-space and 4-space blocks.
  • A stray space before a key, making it a child of the previous line instead of a sibling.

How to narrow it down

  • Turn on whitespace rendering in your editor and scan the failing block for tab characters (→) mixed with spaces (·).
  • Check the line above the reported error first — a missing or extra space there often shifts everything below.
  • Reduce the file: comment out blocks until the error disappears, then re-add lines to isolate the offender.

Examples

Inconsistent sibling indentation (fails)
server:
  host: localhost
   port: 8080

host is indented 2 spaces, port 3 — they are no longer siblings.

Fixed: aligned siblings
server:
  host: localhost
  port: 8080

Every key under server starts at the same column.

How to fix

  • Convert all tabs to spaces (enable “show whitespace” in your editor to spot them).
  • Pick one indent width (2 spaces is the YAML convention) and re-indent the failing block consistently.
  • Paste the file into the YAML validator below — it reports the exact line and column where indentation breaks.
  • Use an editor with YAML-aware formatting (VS Code + YAML extension) to auto-fix alignment.

Watch out

  • YAML forbids tabs for indentation entirely — even one tab inside an otherwise clean file fails strict parsers.
  • Multiline strings (| and >) have their own indentation rules; do not re-indent their content blindly.

Use our tool

Validate YAML

Advertisement

All guides