What is YAML?
YAML is the de facto standard for configuration files in modern DevOps. From Kubernetes deployments to GitHub Actions workflows, YAML's readability makes it the preferred choice for infrastructure-as-code.
YAML Syntax Essentials
- Indentation matters — use spaces only (no tabs). 2 spaces per level is standard.
- Key-value pairs use a colon followed by a space:
key: value - Lists use a dash followed by a space:
- item - Multi-line strings: use
|to preserve newlines or>to fold them
Common YAML Errors
name: app version: 1.0
name: app version: 1.0
name:app port:8080
name: app port: 8080
server: port: 8080 port: 3000
server: port: 8080
How to Format YAML
- 1
Paste your YAML
Copy your YAML content and paste it into the editor. The formatter handles any YAML structure including nested objects, lists, and multi-line strings.
- 2
Format and validate
Click Format to normalize indentation to 2 spaces. The validator checks for syntax errors, duplicate keys, and type coercion issues.
- 3
Review diagnostics
Warnings and errors appear below the editor with line numbers. Duplicate keys are flagged as warnings since they are valid YAML but often indicate bugs.
- 4
Fix or export
Use AI Assist to auto-fix common issues, or copy the formatted output directly.
YAML Multi-Line Strings
| Style | Symbol | Use Case |
|---|---|---|
| Literal | | | Preserves newlines — code, configs |
| Folded | > | Folds newlines — long paragraphs |
| Plain | "" | Single line with escape sequences |
FAQ
What is YAML and where is it used?
YAML (YAML Ain't Markup Language) is a human-readable data serialization format used for configuration files, CI/CD pipelines (GitHub Actions, GitLab CI), Kubernetes manifests, Docker Compose files, and Ansible playbooks. It emphasizes readability over JSON while supporting the same data structures.
What are the most common YAML syntax errors?
The most common YAML errors are: inconsistent indentation (mixing tabs and spaces), missing space after a colon in key-value pairs, incorrect list indentation, duplicate keys at the same level, and using tabs instead of spaces. YAML is whitespace-sensitive, so even one extra space can change the data structure.
Is YAML a superset of JSON?
Yes. YAML 1.2 is a strict superset of JSON, meaning any valid JSON document is also valid YAML. This makes it easy to convert JSON to YAML, but not always the reverse since YAML has additional features like anchors, aliases, multi-line strings, and unquoted strings.
How does YAML handle multi-line strings?
YAML supports two multi-line string styles: the literal block scalar (|) preserves newlines, and the folded block scalar (>) folds newlines into spaces. Use | for code blocks and configuration values, and > for long paragraphs of text.