YAML Formatter

Normalize indentation and spacing in YAML files such as Kubernetes manifests, CI workflows and Docker Compose files, without losing comments.

Loading tool…

About the YAML Formatter

YAML uses indentation for structure, so inconsistent spacing makes files hard to review and easy to break. This formatter runs Prettier's YAML printer, which re-indents nested mappings and sequences to a consistent width, normalizes spacing after : and -, and tidies flow collections — [ main, dev ] becomes [main, dev] and {a: 1} becomes { a: 1 }. Comments, document separators (---), anchors, aliases and block scalars (| and >) are preserved.

Quoted strings are printed with double quotes by default or single quotes when Single quotes is ticked; Prettier keeps whichever quote needs fewer escapes. It never reorders keys, changes values or converts types, so a Kubernetes manifest or Ansible playbook means the same after formatting. Tabs are not offered because the YAML specification forbids tab characters for indentation.

If the document does not parse — for example a key indented one space too far or a tab used for indentation — you get the error with its line and column. Syntax validity is all it checks; it does not validate against a Kubernetes or GitHub Actions schema. The file is processed locally in your browser.

How to use it

  1. Paste YAML or open a .yml / .yaml file.
  2. Choose 2 or 4 spaces and the print width.
  3. Tick Single quotes if your style prefers them.
  4. Copy or download the formatted YAML.

Frequently asked questions

Can YAML use tabs for indentation?
No. The YAML spec allows only spaces for indentation. A tab at the start of a line is a syntax error in conforming parsers.
Does the formatter keep my comments?
Yes. Comments are part of Prettier's YAML syntax tree and stay attached to the nodes they describe.
Will it convert yes/no or on/off values?
No. Scalars are printed as written. Be aware that YAML 1.1 parsers (such as PyYAML) treat unquoted yes, no, on and off as booleans; quote them if you mean strings.

Related tools