YAML Validator Guide — Validate and Fix YAML Online
YAML is powerful and readable, but its whitespace-sensitivity makes it uniquely prone to subtle errors. A missing space, a tab character where spaces are expected, or a value that is accidentally parsed as a boolean can break your entire Kubernetes manifest, GitHub Actions workflow, or application configuration. A YAML validator catches these issues before they reach production.
Why YAML Validation Is Critical
Unlike JSON, which has a strict, unambiguous syntax, YAML's flexibility creates many ways to write incorrect YAML that looks correct to human eyes:
- A tab character looks identical to spaces in most editors
NOlooks like it could be a country code but parses as booleanfalse- Inconsistent indentation may parse without error but produce unexpected nesting
- Colons without trailing spaces cause silent parse failures in some parsers
In a Kubernetes deployment, a single YAML error can prevent a service from deploying — often with a cryptic error message that points to the wrong location.
YAML Syntax Rules
Indentation — Spaces Only, Never Tabs
YAML uses indentation to express structure. The rules are strict:
- Use spaces only — tab characters are illegal in YAML
- Indentation must be consistent within a document (2 spaces or 4 spaces — pick one)
- Child elements must be indented further than their parent
- List items at the same level must have identical indentation
# Valid — consistent 2-space indentation
server:
host: localhost
port: 8080
options:
debug: true
timeout: 30
# Invalid — tab character on "port" line
server:
host: localhost
port: 8080 # TAB character here — syntax error
Colons Must Have a Space After Them
# Invalid — no space after colon
server:
host:localhost # ERROR: missing space
# Valid
server:
host: localhost
Exception: colons in quoted strings and URLs (https://example.com) do not need a space after them.
String Quoting
Most strings in YAML do not need quotes, but you must quote strings that:
- Start with special characters:
:, -, #, {, }, [, ], &, *, !, |, >, ', ", %, @, ` - Look like other types:
"true","null","123","yes" - Contain a colon followed by a space
- Are empty strings:
value: ""
YAML Boolean Gotchas
YAML 1.1 (used by many parsers including PyYAML and some Kubernetes tools) treats several values as booleans:
# These are parsed as TRUE in YAML 1.1
yes, Yes, YES
true, True, TRUE
on, On, ON
# These are parsed as FALSE
no, No, NO
false, False, FALSE
off, Off, OFF
This causes real-world bugs. The Norwegian country code NO parses as boolean false. The word on in a configuration value parses as true. Always quote these values if you mean them as strings: country: "NO".
YAML 1.2 (used by newer parsers) only treats true and false as booleans, but parser behaviour varies. When in doubt, quote strings that look like booleans.
YAML Multiline Strings
YAML supports two multiline string styles:
# Literal block (|) — preserves newlines
description: |
Line one.
Line two.
Line three.
# Folded block (>) — folds newlines into spaces
description: >
This is a long sentence
that will be joined into
a single line.
Common YAML Errors and Their Fixes
Duplicate Keys
# Invalid — duplicate key
server:
host: localhost
host: 127.0.0.1 # Duplicate — second value silently overwrites first
Incorrect List Syntax
# Invalid — dash must be followed by a space
roles:
-admin # ERROR: no space after dash
# Valid
roles:
- admin
Inconsistent Indentation
# Invalid — mixed indentation depths
config:
host: localhost
port: 8080 # Over-indented — makes port a child of host
How to Validate YAML Online
Use the YAML validator on DataConvertProTools:
- Go to DataConvertProTools → Validator tab → select YAML
- Paste your YAML document
- Click Validate — every error appears with line number and description
- Click Auto-Fix to automatically repair tab characters, missing spaces after colons, boolean normalisation, and trailing whitespace
You can also convert validated YAML to JSON using the YAML to JSON converter — useful for checking that the parsed structure matches your intent.
Validate and auto-fix YAML instantly: DataConvertProTools YAML Validator — detects tab characters, bad indentation, boolean traps, and syntax errors. Also converts YAML to JSON, XML, and CSV. Free, private, no signup.