What Is a YAML Formatter?
A YAML formatter validates, reformats, and converts YAML data. YAML is the standard configuration format for Docker Compose, Kubernetes, GitHub Actions, Ansible, and most modern DevOps tooling. This tool validates your YAML syntax in real time, reformats it with consistent indentation, and can convert between YAML and JSON formats.
YAML vs JSON
YAML is a superset of JSON with extra features: comments (# for inline notes), multi-line strings (using | or >), anchors (&name and *name for reuse), and cleaner syntax (indentation instead of brackets). JSON is better for API payloads and programmatic data; YAML is better for configuration files that humans read and edit frequently.
How to Use This YAML Formatter
- Paste your YAML — Enter raw or messy YAML into the input area.
- Read the result — Output updates as you type: the YAML is parsed and written back with 2-space indentation, and the JSON button shows the JSON version. Format replaces your input with the formatted YAML, so comments and anchors in the input are lost; copy your original first if you need it.
- Check errors — Invalid YAML shows the parser's message with the line and column, for example a duplicated key or a tab used for indentation.
- Copy the result — Click Copy to grab the cleanly formatted YAML for your configuration files.
Worked example: what Format changes in a real config
Since October 13, 2026 the formatter uses the yaml library (2.6.1, ISC licence, self-hosted), which keeps the document as a tree of nodes rather than plain data. Format changes indentation (2 or 4 spaces) and spacing only; comments, anchors, every number as written and multiple documents survive. We typed a deploy config into the page in Chromium, old version against new (script: _ops/checks/yaml/):
| Input | Old output (js-yaml 4.1.0 dump) | Output now |
|---|---|---|
| # Deploy config, inline comments | Removed | Kept |
| version: 3.10 | 3.1 | 3.10 |
| mode: 0755 | 755 (a different number to a YAML 1.1 reader, which reads 0755 as octal 493) | 0755 |
| size: 1e3, mask: 0x1F | 1000, 31 | 1e3, 0x1F |
| released: 2026-10-13 | 2026-10-13T00:00:00.000Z | 2026-10-13 |
| country: NO | 'NO' (quoted) | NO, as written |
| defaults: &defaults … <<: *defaults | Anchor and merge key expanded into copies | Kept |
| Two documents separated by --- | Rejected ("expected a single document") | Both formatted |
The formatted text loads to exactly the same data as the input in PyYAML 6 (a YAML 1.1 loader) and in the yaml library (YAML 1.2), at both indent settings. The JSON view still shows the parsed data, so there 3.10 is 3.1 and aliases are expanded; a file with several documents becomes a JSON array.
YAML 1.2 here, YAML 1.1 in many of your tools
The Norway problem comes from YAML 1.1, where yes, no, on and off are booleans. YAML 1.2 (2009) reduced booleans to true and false, and this tool follows 1.2. PyYAML 6.0.3, which many Python tools still use, follows 1.1: on the same file it returned country: False, enabled: True and turned the on key into the boolean True. A file can therefore validate here and still mean something different to a 1.1 reader. Format keeps such words exactly as you wrote them, so if a value like NO must be a string for a 1.1 reader too, quote it yourself ('NO'); quoted, it is a string in both versions.
What the validator checks
- Several documents in one file are fine. A Kubernetes manifest with --- between resources is validated and formatted document by document (it used to fail with "expected a single document in the stream").
- Duplicate keys.
a: 1thena: 2is reported as a duplicated mapping key with its line and column. The spec requires keys to be unique, though some parsers keep the last value silently. - Tabs in indentation. Reported with position. The 1.2 spec allows only spaces for indentation.
Sources
Checked on .
Frequently Asked Questions
Built by Derek Giordano · Part of Ultimate Design Tools