Skip to content

YAML formatter

Re-indents YAML. Comments and key order stay where they were.

Ctrl+Enter or ⌘+Enter runs this tool immediately.

YAML indent
YAML input
Formatted YAML

Waiting for input.

Parsing stays in this browser. Input is not uploaded or saved.

How to use this tool

  1. Paste YAML, or load the sample. It has uneven indentation and two documents.
  2. Choose 2 or 4 spaces.
  3. Copy or download the result. Invalid YAML is reported and nothing is written.

Supported formats and limitations

  • Comments, quote styles, anchors, aliases, and key order are kept. Extra spaces inside a line are removed.
  • Long strings are not wrapped onto new lines.
  • Flow collections such as {a: 1} stay on one line, with spaces added inside the brackets.
  • Duplicate keys and tab indentation are errors, not fixed for you.

Examples

Uneven list indentation

List items and nested keys are re-indented to the width you chose.

ports:
-   80
-  443

Two documents

Each document is formatted, and the --- separators are kept.

a: 1
---
b: 2

Common errors and solutions

Tabs are not allowed as indentation
Replace the tab with spaces. The formatter does not guess how wide a tab should be.
Map keys must be unique
Delete or rename one of the repeated keys.

FAQ

Are comments kept?
Yes. Comments stay on the same line or above the same key.
Will it change yes to true or quote my strings?
No. Values and quote styles are written back the way they were parsed. Only indentation and spacing change.
Is the YAML uploaded?
No. It is formatted in your browser.

Read next

Related tools

  • YAML validator

    Check YAML syntax without converting or rewriting it. Errors include a line and column when the parser provides them, and valid input is left unchanged.

  • YAML to JSON converter

    Convert YAML configuration to readable or compact JSON in the browser. Comments are dropped, and parse errors include line and column when the parser reports them.

  • Kubernetes YAML syntax check

    Check the YAML syntax of a Kubernetes manifest, including files with more than one document. This does not check apiVersion, required fields, or unknown kinds.