YAML Formatter

Beautify YAML with consistent indentation, expand inline {...} and [...] blocks, optionally sort keys, and catch syntax errors with line numbers. Only need a pass/fail check? Use the YAML validator. Runs 100% in your browser.

YAML input

Formatted YAML

What the YAML checker catches

  • Indentation errors such as a key indented deeper than its siblings, or tabs used for indentation.
  • Duplicate keys in the same mapping (many parsers silently keep the last one; this reports the line).
  • Unclosed flow collections and quotes like [a, b or "text.
  • Unknown aliases (*name without a matching &name anchor) and bad multi-document separators.

How formatting works

  • YAML is parsed using its version directive, or YAML 1.2 by default, then printed in block style with consistent indentation.
  • The formatter refuses numeric scalars whose spelling it cannot safely preserve. YAML 1.1 and 1.2 can interpret the same scalar differently.
  • Comments and anchors are retained where possible; review the output and keep the original. Sorting is disabled for files with anchors or aliases.
  • Custom tags are preserved, but their application-specific meanings cannot be validated here.
  • Multi-document files (separated by ---) are formatted document by document.
  • Need JSON instead? Use YAML to JSON or go the other way with JSON to YAML.

FAQ