YAML error: tabs are not allowed for indentation

YAML uses indentation to express nesting, and the specification only allows spaces for it, because tab widths differ between editors and would make the structure ambiguous. A single tab at the start of a line is enough to stop the parser. Tabs are invisible in most editors, so the line often looks perfectly aligned; PasteKit marks each tab-indented line.

Seen as:

  • yaml.scanner.ScannerError: while scanning for the next token found character '\t' that cannot start any token
  • yaml: line 2: found character that cannot start any token
  • YAMLException: tab characters must not be used in indentation (2:1)
  • Tabs are not allowed as indentation at line 2, column 1

Input

Settings

History

Load from URL

Common causes

1. The editor inserted a tab when you pressed Tab

Editors configured for Makefiles or Go insert real tab characters. Replace them with spaces (two per level is the common convention) and set the editor to indent YAML with spaces.

Before
server:
	port: 8080
After
server:
  port: 8080

2. Mixed tabs and spaces that look aligned

A file edited by several people can contain lines indented with spaces next to lines indented with a tab. They line up on screen, but only the space-indented ones are valid.

Before
database:
  host: db.internal
	port: 5432
After
database:
  host: db.internal
  port: 5432

3. Content pasted from a tab-separated source

Copying from a spreadsheet, a TSV file or terminal output brings tabs along. Inside a quoted string or a block scalar a tab is just text, but at the start of a line it is indentation.

Before
labels:
	team: platform
	tier: backend
After
labels:
  team: platform
  tier: backend

Frequently asked questions

Are tabs allowed anywhere in YAML?

Yes, inside quoted strings, inside block scalars (| and >) and, in YAML 1.2, as separation between tokens on a line. They are only forbidden as indentation.

How do I find tabs in a YAML file?

Turn on “render whitespace” in your editor, or search with the regex ^\t. In VS Code, “Convert Indentation to Spaces” in the command palette fixes the whole file at once.

Can I stop this from happening again?

Add an .editorconfig with indent_style = space for *.yml and *.yaml files, and run a YAML linter such as yamllint in CI.

Related