YAML Formatter & Validator — YAML 1.2 Specification Technical Guide
Format, validate, and pretty-print YAML documents in your browser. Detect indentation errors, duplicate keys, and invalid anchors per YAML 1.2 spec.
01. YAML 1.2 Specification: Structure, Scalars & Collections
YAML (YAML Ain't Markup Language) version 1.2 is defined at yaml.org. YAML is a human-readable data serialization format for configuration files, data exchange, and CI/CD pipeline definitions (GitHub Actions, Kubernetes manifests). YAML 1.2 is a superset of JSON — all valid JSON documents are valid YAML 1.2 documents.
YAML uses indentation with spaces (never tabs) to define nesting — the most common source of parse errors. YAML 1.2 introduces strict boolean handling: only true and false (lowercase) are booleans. The YAML 1.1 values yes, no, on, off, True, False were booleans but YAML 1.2 treats them as plain strings.
Anchors and aliases enable DRY configuration reuse: ampersand defines an anchor and asterisk references it. The Norway Problem (country code "NO" parsed as boolean false in YAML 1.1) is resolved in YAML 1.2 by treating unquoted yes/no as strings.
- YAML 1.2 §2.1: Documents start with --- and end with ... (optional for single docs).
- Indentation: 2-space conventional; 4-space acceptable; tabs strictly forbidden.
- YAML 1.2 Booleans: Only true/false — yes/no/on/off are strings in YAML 1.2.
- Anchors & Aliases: & defines anchor, * references it — DRY configuration reuse.
- Multi-line scalars: | (literal) preserves newlines; > (folded) folds newlines to spaces.
02. Common YAML Pitfalls & Parsing Edge Cases
Implicit type coercion creates silent data corruption: "1.0" becomes float 1.0, "0755" becomes octal 493 in YAML 1.1, and "null" becomes a null value. Always quote ambiguous values that should remain strings.
Duplicate keys in YAML mappings produce undefined behavior in many parsers (last value silently overwrites). This tool detects and flags duplicate mapping keys as errors. PyYAML defaults to YAML 1.1 behavior — a common source of production bugs when processing Kubernetes and Ansible files.
- Norway Problem: Quote "NO", "YES", "ON", "OFF" when not boolean values.
- Octal trap: "0755" becomes 493 in YAML 1.1 — quote to keep as string.
- Null coercion: "~" and "null" become null; always quote if string is intended.
- Duplicate keys: Last value silently overwrites — this tool flags duplicates as errors.
Frequently Asked Questions (FAQ)
Why does YAML forbid tabs for indentation?
The YAML 1.2 specification explicitly forbids tabs because tab width is application-defined and inconsistent across editors. Only space characters (U+0020) are valid for YAML indentation.
What is the difference between YAML 1.1 and 1.2?
YAML 1.2 restricts booleans to only true/false. In YAML 1.1, yes, no, on, off, True, False were all booleans — breaking change that affects PyYAML (defaults to 1.1) and many Kubernetes configs.
Is my confidential data uploaded to external servers when using YAML Formatter & Validator?
No. Core processing in YAML Formatter & Validator executes in volatile browser memory without server uploads. Inputs to local tools are not logged on remote servers; optional cloud-assisted features require user consent.
Can I use YAML Formatter & Validator offline without an active internet connection?
Offline use requires the page and its tool assets to finish caching first. Core transformations can then run locally; optional AI and contact delivery require internet.
Is YAML Formatter & Validator free to use with any rate limits or paywalls?
Core tools are free to use without an account. Device memory and tool-specific safety limits apply. Optional AI and online contact services have usage limits.