YAML Formatter & Validator
Paste YAML to format and validate it instantly. Get line and column error markers for every syntax problem. Nothing leaves your browser.
How to use
- Paste your YAML into the left pane. The tool validates it live as you type and auto-formats on the right.
- Errors appear in the output pane with line and column numbers. Fix each flagged line and watch the status badge turn green.
- Once valid, click Format to normalize indentation, then Copy output to grab the cleaned YAML.
Frequently asked questions
What is YAML?
YAML (YAML Ain’t Markup Language) is a human-readable data serialization format that uses indentation to express structure. It is the standard config format for Docker Compose, GitHub Actions, Kubernetes, Ansible, and most CI/CD pipelines. Unlike JSON it supports comments (#), multi-line block strings, and value reuse via anchors and aliases.
Why does my YAML fail on tab characters?
The YAML spec explicitly forbids tabs for indentation — only spaces are allowed. Many editors silently insert a tab on the Tab key. Set your editor to “indent with spaces” (2 spaces is the DevOps standard). This tool flags every tab with the exact line and column number.
What is the difference between YAML and JSON?
YAML is a superset of JSON — every valid JSON document is valid YAML. YAML adds comments (#), multi-line strings (| literal and > folded), anchors for reuse, and more relaxed quoting. JSON is safer for APIs; YAML is preferred for config files humans write daily.
How do I write a multi-line string in YAML?
Use block scalar indicators: | (literal) preserves newlines exactly; > (folded) converts single newlines to spaces. Add - to strip the trailing newline (|-) or + to keep extra trailing newlines (|+). Both are followed by an indented block on the next line.
What are YAML anchors and aliases?
Anchors (&name) mark a reusable block; aliases (*name) paste it. The merge key (<<:) includes an anchored map and lets you override fields. Define shared settings once under defaults: &defaults, then merge with <<: *defaults in each environment block.
Is YAML case-sensitive?
Yes. In YAML 1.2 only true and false are boolean. In YAML 1.1 (older PyYAML), Yes, No, On, Off are also boolean. Always quote strings that look like booleans if you mean plain text.
What is the difference between YAML 1.1 and 1.2?
YAML 1.2 removed the boolean aliases yes/no/on/off and changed octal from 0755 to 0o755. Modern runtimes (Go yaml.v3, Rust serde-yaml 0.9+, Ruby 3+) use 1.2. Python’s PyYAML defaults to 1.1; use ruamel.yaml for 1.2.
Why do some YAML strings need quotes?
YAML auto-detects types. Strings that look like booleans, nulls (null, ~), numbers, or contain : # { } [ ] | > ! & * must be quoted. Single quotes disable escape processing; double quotes allow \n and \t. When unsure, quote.
How do I use YAML in GitHub Actions?
Workflows live in .github/workflows/*.yml. Top-level keys: name, on, jobs. Each job has runs-on and steps. Steps use uses for actions or run for shell. Indent 2 spaces. Tip: quote 'on': to avoid YAML 1.1 boolean confusion, though GitHub’s parser accepts the bare form.
How does this validator work without an external library?
It scans line by line: tabs, inconsistent indent steps, unclosed quotes, colons without a space separator, and duplicate top-level keys. This catches the majority of real-world DevOps config errors without shipping a full parser, keeping the page under 15 KB gzipped for fast mobile load.
Examples
Docker Compose service
services:
web:
image: nginx:1.27
ports:
- "8080:80"
environment:
- NODE_ENV=production
volumes:
- ./html:/usr/share/nginx/html
GitHub Actions workflow
name: CI
'on':
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm test
Anchors & merge keys
defaults: &defaults timeout: 30 retries: 3 log_level: info production: <<: *defaults host: prod.example.com log_level: warn
About this YAML formatter
YAML (YAML Ain’t Markup Language, originally “Yet Another Markup Language”) was designed as a human-friendly alternative to XML for configuration files. It reached widespread adoption through Ruby on Rails, which chose it for database configuration, and has since become the dominant format for infrastructure tooling: Docker Compose, Kubernetes manifests, Ansible playbooks, Helm charts, GitHub Actions, CircleCI, and Cloudflare Pages all rely on YAML.
The most common YAML errors in practice are not schema errors — they are syntax errors that prevent the file from parsing at all. Tabs instead of spaces cause an immediate parse failure with a cryptic “found character that cannot start any token” message. Off-by-one indentation attaches a key silently to the wrong parent object. Unquoted colons in values break the key-value parser. These are exactly the errors this tool catches, with precise line and column numbers.
Privacy: Every character you paste stays in your browser. Open DevTools → Network and interact with the formatter — you will see zero outbound requests from the tool. All tokenization and formatting runs in local JavaScript. This is literally verifiable in your browser, not a policy claim.
The formatter normalizes output by stripping trailing whitespace from every line and collapsing more than two consecutive blank lines into one. It does not reorder keys, alter values, or change your indentation depth. The output is deterministic — the same input always produces the same output.
For advanced YAML features like custom tags, multi-document streams (separated by ---), or anchors spanning multiple files, a full parser like js-yaml or Python’s ruamel.yaml gives more complete error messages. This tool is optimized for the 95% case: DevOps config files using maps, lists, strings, numbers, and booleans — the kind you write for Docker, Kubernetes, and GitHub Actions every day.