Common YAML errors and how to fix them
Reviewed 23 November 2026 · 6 min read · Written and maintained by Toolnexo
YAML is easy to read and easy to break. A single tab, a stray colon or a missing bracket turns a working file into an error, and the message does not always point at the line you need to fix. This guide covers the mistakes that cause most failures, the exact message the parser gives for each, and how to fix them. The messages below come from the YAML validator on this site, which checks the text in your browser, so your configuration is not uploaded.
Fix the first error first
A parser reads from the top, and one mistake can make the next lines look wrong too. The first error is the one to fix. Fix it, check again, and many of the later ones vanish.
Tabs as indentation
YAML does not allow tab characters for indentation, only spaces. A file edited in a tool that inserts tabs gives the message Tabs are not allowed as indentation. If line 1 is a: and line 2 is b: 1 indented with a tab, the error is reported at line 2, column 1.
Replace the tab with spaces, normally two per level. Most editors can show whitespace or convert tabs to spaces for a file in one step.
Duplicate keys
The same key twice in one mapping is an error in YAML 1.2, with the message Map keys must be unique. In a file with the three lines a: 1, b: 2 and a: 3, the error is at line 3, column 1, where the second a begins.
Some tools silently keep the last value, which hides the mistake until something behaves oddly, so it is worth catching it here. Merge the two entries or rename one.
A colon followed by a space inside a value
A colon followed by a space means key and value. If a value itself contains one, the parser tries to read a second mapping and fails. The line key: value: bad gives Nested mappings are not allowed in compact mappings at line 1, column 6.
Put the value in quotes: key: "value: bad". Values that start with an asterisk, an ampersand, an @ sign or a backtick, or that contain a space followed by a hash sign, also need quotes.
Unclosed brackets and wrong indentation
An unclosed flow list such as list: [1, 2 followed by next: 3 on the next line reports Flow sequence in block collection must be sufficiently indented and end with a ] at line 2, column 1. The position is the line after the mistake, because that is where the parser realises the list never ended. When an error points at the start of a line, look at the end of the one above it.
A file of several documents separated by --- is checked one document at a time, and each problem is labelled with its document number, so you know which part of a long file to look at.
An alias with no anchor
Anchors (&name) and aliases (*name) let you reuse a block. An alias to a name that was never defined, as in a: *missing, gives Unresolved alias (the anchor must be set before the alias): missing. This one has no line number, because it is found after the text has parsed. The anchor has to appear before the alias in the file.
The yes, no and on trap
In YAML 1.2, which the validator follows, the words yes, no, on and off are plain text. In YAML 1.1, which some older parsers such as PyYAML still follow, they are booleans. So country: no passes the validator but can be read as false by an older tool, which is why a list of country codes that includes NO can quietly break.
If your file is read by more than one tool, put such values in quotes, for example country: "no", so every parser sees a string.
What a validator cannot tell you
- It checks syntax, not meaning. A Kubernetes, Docker Compose or CI file can be valid YAML and still have a wrong or missing field. Use the tool that reads the file for that.
- Formatting re-indents with two or four spaces and can sort keys. Comments and anchors are kept, but the spacing is rewritten and quoting may change where YAML allows more than one style. For example a: 1 becomes a: 1, and a list indented six spaces moves back to two.
- Up to 2 million characters can be checked, and nothing is sent anywhere.
- If you need JSON instead, the JSON to YAML converter handles the conversion.
Put it into practice
YAML Validator
Check YAML for syntax errors with line and column numbers, find duplicate keys and bad indentation, and tidy the formatting.
Runs in your browserJSON to YAML Converter
Convert JSON to YAML and YAML back to JSON in your browser, with a choice of indent, clear error messages and support for multi-document …
Runs in your browserJSON Validator
Check any JSON for syntax errors with the exact failure position, plus a structure summary: objects, arrays, keys, leaf values and nestin…
Runs in your browserJSON Formatter & Validator
Format, validate and minify JSON with exact error positions, a collapsible tree, optional key sorting and one-click copy or download: par…
Runs in your browserHow this guide is maintained
This page is reviewed when the related tools change. It describes what the published tools actually do: the tools run in your browser tab, so your files stay on your device. If you find something inaccurate, email [email protected] and it will be corrected.
Other guides
- How to merge PDFs without uploading them6 min · 17 November 2026
- OCR a scanned PDF: accuracy, limits and privacy7 min · 17 November 2026
- Compress a PDF without destroying readability6 min · 17 November 2026