02.4YAML tabs
YAML tab fixer
YAML does not allow tabs for indentation. Paste a file that fails with “found character that cannot start any token” to see every tab, rewrite it with spaces at a consistent depth and check that the result parses.
or drop a file on this box
Parser check
Original: parse error at line 2, column 1
Tabs are not allowed as indentation.
Fixed: valid YAML
One document parsed without errors.
Tabs on 16 lines: 14 in indentation, 1 after key: or -, 2 inside block scalar indentation. 16 lines rewritten with spaces.
The errors a tab causes
found character '\t' that cannot start any token: PyYAML, Ruby and Go (and so Kubernetes, Ansible and Docker Compose) hitting a tab at the start of a line, or right afterkey:or-.tab characters must not be used in indentation(js-yaml) andTabs are not allowed as indentation(theyamlpackage).mapping values are not allowed hereorbad indentation of a mapping entry: often a tab that an editor showed at one width and the parser counted differently.
The fixer expands each tab to the column it reached in your editor (set Tabs were to match; for files that mix tabs and spaces it is guessed), then rebuilds the indentation level by level, so children stay inside their parents. Keys under a - list item stay lined up with the first key. Block scalars (| and >) keep their content as it is, tabs inside it included. Both versions are then parsed with the yaml package, so you can see where the original fails and that the fixed one does not.
Questions
Are tabs ever allowed in YAML?
Inside quoted strings and block scalar content, yes, and YAML 1.2 allows them as separators. libyaml-based parsers still reject a tab after a colon or dash, which is why that option is on.
Which tab width should I pick?
The width your editor showed tabs at, usually 2, 4 or 8. For a file that mixes tabs and spaces, the guess is the width at which the nesting comes out consistent; check the Original view to confirm.
Is my file uploaded?
No. Fixing and parsing happen in your browser.