Fix YAML indentation

Re-indent a file written by several editors to one consistent step. The detected indentation and any tab characters are reported; values are verified unchanged.

Default. true/false/null/ints/floats resolve per YAML 1.2.2 core; yes/no/on/off and dates stay strings.
Style options

Source

14 lines · rev 1

Paste or type YAML. Drop a file here to open it. Your source changes only when you apply a result.

Checking…Re-checking the latest source…

Preparing preview…

Download
Not editedNo preview yet.

Indentation is structure in YAML

In YAML, indentation decides which key a value belongs to. That is why FormatYAML never re-indents text with search and replace: it re-lays out the parsed document, then proves the new layout produces the same tree.

Tabs are not allowed for indentation in YAML. If your file has them, the parser reports the exact line and the formatter refuses to guess; the Invisible tab shows where they are.

Indented or flush sequences

Both styles are valid. “Indented” puts list dashes one level under their key; “flush” (used by kubectl and many Kubernetes examples) keeps dashes at the key’s column. Pick one with “Indent sequences”.

Block scalars keep their internal relative indentation. A block with leading spaces gets an indentation indicator that matches the new step, and the decoded text is checked byte for byte.

Questions

What indent does my file use?
The Checks tab shows the most common indentation step detected in your source, next to the step you chose.
Can I convert 4 spaces to 2?
Yes: set Indent to 2. Nested sequences, block scalars and comments are re-indented consistently.

Other tools