Why YAML Validation Matters
YAML is the dominant configuration language for DevOps: Kubernetes manifests, Docker Compose files, Ansible playbooks, GitHub Actions workflows, CI/CD pipelines — all YAML. But YAML's significant whitespace means a 1-character indentation error can create an entirely different structure. Worse, YAML has implicit type conversion: yes becomes boolean true, 1.0 becomes float 1.0 not string "1.0", and NO becomes boolean false. A validator catches both syntax errors and type surprises.
The Most Common YAML Errors
- Indentation errors: Mixing tabs and spaces (YAML forbids tabs — spaces only). Using 3 spaces where 4 or 2 is expected. Inconsistent indentation within a block.
- The Norway Problem:
country: NO— YAML interpretsNOas boolean false, not the string "NO" (which is Norway's ISO country code). Always quote:country: "NO". - Colon-in-string issues:
url: https://example.combreaks because the colon afterhttpslooks like a new mapping key. Quote the value or the entire key. - List-of-strings shorthand:
tags: [docker, kubernetes]works. Buttags: [docker, kubernetes, nginx]with trailing comma fails on some parsers. - Anchors and aliases:
&aliasdefines a reference;*aliasuses it. Aliases that reference undefined anchors cause silent failures or parse errors depending on the parser.
YAML Type Gotchas
YAML 1.1 auto-converts these values — often unexpectedly:
value: yes # boolean true (not string)
value: no # boolean false
value: on # boolean true
value: off # boolean false
value: 1.0 # float, not string
value: 0123 # octal! 83 in decimal
value: 0x1A # hex! 26 in decimal
Always quote strings that could be misinterpreted, or use YAML 1.2 which tightened these rules. When in doubt, single-quote your string values.
Formatting YAML
Consistent formatting makes YAML reviewable in PRs: use 2-space indentation (the YAML community standard), quote all string values for safety, sort mapping keys alphabetically for diffs, and use block style (> or |) for multi-line strings instead of inline backslash escaping.
Validate YAML Instantly
Paste your YAML into ToolsVito's YAML Validator to check syntax, find indentation errors with exact line numbers, and format to canonical style. All validation runs in your browser.