HomeToolsFormattingYAML Formatter

YAML Formatter

Format, validate, and pretty print your YAML files with customizable indentation levels.

Formatting
Indent:
Input YAML
Formatted YAML

What is a YAML Formatter?

A YAML Formatter is a developer utility that parses YAML (YAML Ain’t Markup Language) data, validates its syntax, and formats its layout. Because YAML relies strictly on indentation, this tool ensures spacing consistency, auto-corrects list and key formats, and flags common issues like forbidden tab characters.

Features

  • Custom Indentation: Pretty print using 2 spaces or 4 spaces.
  • Auto Indentation Mapping: Automatically detects the original indentation structure and translates it to your desired output spacing.
  • Tab Detection: Highlights where tab characters are wrongly used instead of spaces.
  • Multiline String Support: Safely formats multiline strings (using | and >) without disrupting relative formatting.
  • Comments and Spacing: Retains key-value comments while standardizing spaces around keys, list markers, and values.

Example Input

database:
  host: "localhost"
  port: 5432
  users:
  - name: "admin"
    roles:
    - "superuser"

Example Output

database:
  host: "localhost"
  port: 5432
  users:
    - name: "admin"
      roles:
        - "superuser"

Contribute

Find a bug or want to suggest an improvement to this tool?