YAML Formatter

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

  1. Paste your YAML — Enter raw or messy YAML into the input area.
  2. 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.
  3. 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.
  4. 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/):

InputOld output (js-yaml 4.1.0 dump)Output now
# Deploy config, inline commentsRemovedKept
version: 3.103.13.10
mode: 0755755 (a different number to a YAML 1.1 reader, which reads 0755 as octal 493)0755
size: 1e3, mask: 0x1F1000, 311e3, 0x1F
released: 2026-10-132026-10-13T00:00:00.000Z2026-10-13
country: NO'NO' (quoted)NO, as written
defaults: &defaults … <<: *defaultsAnchor and merge key expanded into copiesKept
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

Frequently Asked Questions

What is YAML?
YAML is a human-readable data format used for configuration files, CI/CD pipelines, Kubernetes manifests, and Ansible playbooks. It uses indentation instead of brackets, making it cleaner than JSON or XML.
What is the difference between YAML and JSON?
YAML is a superset of JSON — valid JSON is also valid YAML. YAML adds comments, multi-line strings, anchors, and indentation-based structure. JSON is more compact for APIs; YAML is preferred for configuration.
How do I validate YAML?
Paste it into this tool. It parses the YAML as you type and shows the parser's first error with its line and column (for example a duplicated key, a tab in the indentation or a bad mapping). Files with several documents separated by --- are checked document by document.
Why is YAML indentation important?+
YAML uses indentation to define structure — the nesting of data. Unlike JSON (which uses braces) or XML (which uses tags), YAML relies entirely on whitespace to determine parent-child relationships. Incorrect indentation changes the data structure, which can cause silent bugs in configuration files.
What is the difference between YAML and JSON formatting?+
JSON formatting is flexible — braces and brackets define structure regardless of whitespace. YAML formatting is critical — indentation IS the structure. This makes YAML more human-readable but also more error-prone. A misplaced space in YAML can change data hierarchy; in JSON it would just affect aesthetics.
Can YAML formatting change the data?+
Not here: Format only changes indentation and spacing. Comments, anchors and merge keys, numbers such as 3.10 and 0755, dates and multiple documents are kept as written, and in our test the formatted file loaded to the same data in both a YAML 1.1 and a YAML 1.2 parser. The JSON view is different by nature: it shows parsed data, so 3.10 becomes 3.1 there.

📖 Learn More

Related Article JSON vs YAML vs XML: Complete Data Format Guide →

📖 Learn More

Related Article How to Format & Validate YAML Online →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service