Developer Tools
YAML Formatter & Validator
Format and validate YAML online. Detect syntax errors, pretty-print with custom indent, and convert JSON to YAML - all in your browser.
What is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data serialisation format used extensively for configuration files: Docker Compose, Kubernetes manifests, GitHub Actions workflows, Ansible playbooks, and many more. Its whitespace-based syntax is easy to read and write, but a misplaced indentation or stray character will break the file entirely.
Why use a YAML formatter?
A formatter catches syntax errors before they reach production, normalises indentation so that YAML from different sources looks consistent, and makes deeply nested structures easier to read. This tool also lets you switch to the JSON view to confirm exactly what your YAML parser will see after loading the file.
JSON to YAML conversion
Many APIs return JSON. When you need to put that data into a YAML configuration file, manual conversion is tedious and error-prone. Switch to JSON -> YAML mode, paste your JSON, and get clean YAML instantly.
Common YAML pitfalls
YAML's implicit typing is the source of many subtle bugs:
- Boolean ambiguity: in YAML 1.1 (used by PyYAML and many older parsers),
bare words like
yes,no,on,off,true, andfalseare parsed as booleans. In YAML 1.2 (stricter, used by newer parsers), onlytrueandfalseare booleans. - The Norwegian problem:
NO(the ISO 3166-1 alpha-2 country code for Norway) parses asfalsein YAML 1.1. Similarly,country: NOin a config file will silently becomefalsein PyYAML. Always quote strings that happen to match YAML keywords:country: "NO". - Numeric confusion: bare values like
1.0,1e3, and0x1Fare parsed as numbers. Phone numbers and version strings should be quoted.
Multiline string syntax
YAML provides two block scalar styles for multiline strings, each with three chomping options:
- Literal block (
|): preserves newlines exactly as written. Useful for shell scripts, SQL, or any text where line breaks are meaningful. - Folded block (
>): folds newlines into spaces (like reflowing a paragraph). Single blank lines become newlines in the output.
Chomping indicators control trailing newlines:
-
|-or>-- strip: remove all trailing newlines. -
|or>- clip (default): keep exactly one trailing newline. -
|+or>+- keep: preserve all trailing newlines.
YAML anchors and aliases
Anchors and aliases allow you to reuse content within a YAML document, reducing repetition in complex configurations:
-
&anchor-name- define an anchor on a value or mapping. -
*anchor-name- reference (alias) the anchored value. -
<<: *anchor-name- merge key: merge all key-value pairs from the anchored mapping into the current mapping (useful for shared defaults).
Example using merge keys in a Docker Compose-style config:
defaults: &defaults
restart: unless-stopped
logging:
driver: json-file
web:
<<: *defaults
image: nginx:alpine
ports:
- "80:80"
api:
<<: *defaults
image: node:20
ports:
- "3000:3000"
Privacy
All processing runs in your browser using the open-source js-yaml library. Nothing is uploaded to any server.