Yaml Viewer
What is a Yaml Viewer?
YAML relies entirely on indentation for structure, so a misplaced space can silently change meaning or break a deployment. The YAML formatter re-indents your document consistently, validates that it parses and makes nested structures easy to read. It is handy for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Helm values and Ansible playbooks.
How to use it
- Paste YAML.
- Fix any reported syntax errors.
- Copy the formatted output.
Example
Input with inconsistent indentation and flow style:
services:
web:
image: nginx:1.27
ports: ['80:80']
db: {image: postgres:16, environment: {POSTGRES_PASSWORD: example}}Formatted output:
services:
web:
image: nginx:1.27
ports:
- '80:80'
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: exampleCommon YAML errors
- Tabs: YAML forbids tab characters for indentation.
- Missing space after a colon:
key:valueis a string, not a mapping. - Inconsistent indentation between sibling keys.
- Unquoted special values:
80:80port mappings,yes/no, version numbers like1.10and values starting with*,&or@should be quoted. - Duplicate keys: many parsers silently keep only the last one.
Tips
- Use 2-space indentation, the de facto standard.
- Add
yamllintto CI to catch problems before deployment. - Comments are generally preserved only by formatters that work on the text; parse-and-dump formatting may drop them.
Frequently Asked Questions
Why does YAML not allow tabs?
The YAML specification forbids tabs for indentation to avoid ambiguity between different tab widths.
How many spaces should YAML use?
Any consistent number works, but 2 spaces is the common standard for Kubernetes, Compose and CI files.
Why should Docker port mappings be quoted?
Unquoted values like 22:22 can be misread by some YAML 1.1 parsers as base-60 numbers. Quoting keeps them as strings.
Does formatting keep my comments?
It depends on how the formatter works. Parse-and-dump formatting can drop comments, so check before replacing a commented file.