What the error means
YAML defines indentation in terms of spaces only. The specification forbids tab characters for indentation outright, because a tab has no fixed width — one editor shows it as two columns, another as eight — and YAML's structure depends on columns lining up exactly. tab characters must not be used in indentation means the parser found a tab where it was measuring the indentation of a line.
In the example, the two lines under server: begin with a tab. They look correctly nested in most editors and are rejected by every conforming parser.
Why it happens
- The editor inserts tabs on the Tab key. Many editors do this by default for files whose type they do not recognise, and a
.ymlfile with an unusual name or no extension is treated as plain text. - Copying from a terminal or a chat window that preserved a tab from the original source.
- A Makefile habit. Makefiles require tabs, and people who write both often carry the muscle memory over.
- Mixed indentation after a merge, where one side of the file used tabs and the other spaces. The tab lines look aligned but are not.
How to fix it
- Paste the file into the validator above. The error card gives the line and column of the first tab.
- Replace the tab with spaces. Two spaces per level is the common convention; what matters is that sibling keys use the same number.
- Search the whole file for remaining tabs — most editors accept
\tin a search box — and replace them all in one operation. A file that had one tab usually has more. - Set the editor to insert spaces for YAML: "Insert Spaces" or
expandtab, plus an.editorconfigentry (indent_style = space) so the setting travels with the repository.
The corrected example, with spaces:
server:
host: example.com
port: 8080
If it still fails
- A tab inside a value is allowed; only tabs in the indentation are not. If the error persists after replacing what you can see, String Inspector lists every tab and other invisible character with its exact position.
- Some older parsers report the same problem as
bad indentation of a mapping entryrather than naming the tab. If you get that message and the indentation looks right, check for tabs before anything else. - Files generated by a template engine may re-introduce tabs on every run; fix the template, not just the output.
Related errors
bad indentation of a mapping entry
Every key in the same mapping must start in the same column, indented with spaces only. Align the offending line with its siblings and replace any tab with spaces.
end of the stream or a document separator is expected
Separate multiple documents with a --- line, or nest the extra content under a key. Each YAML document may hold only one top-level value.