YAML Formatter

Normalize indentation, fix spacing, and beautify YAML files

Indent:

Formatted YAML will appear here...

What is YAML Formatter?

YAML (YAML Ain't Markup Language) is a human-friendly data serialization format used in configuration files (Docker Compose, Kubernetes, GitHub Actions, Ansible, etc.). Improperly formatted YAML — inconsistent indentation, missing spaces after colons, or accidental tabs — can cause hard-to-trace parse errors. This formatter normalizes your YAML to a consistent style.

How to Use

  1. Paste your YAML into the editor.
  2. Select the indentation size (2 or 4 spaces).
  3. Click "Format" to normalize and beautify the YAML.
  4. Check the warnings panel for tab characters or other issues.
  5. Copy the formatted output.

Why Use This Tool?

Normalizes inconsistent indentation to your chosen size (2 or 4 spaces)
Adds missing spaces after colons (key:value → key: value)
Fixes list item spacing (-item → - item)
Collapses multiple consecutive blank lines into one
Catches tab characters before they cause parser errors

Tips & Best Practices

  • YAML is whitespace-sensitive — always use spaces, never tabs
  • Keep indentation consistent: pick 2 or 4 spaces and stick to it throughout the file
  • String values that look like numbers (e.g. version: "1.0") should be quoted
  • Colons inside values must be quoted: url: "https://example.com"
  • Use the YAML Validator to check syntax after formatting

Frequently Asked Questions

Why does YAML not allow tabs?

The YAML specification explicitly prohibits tab characters for indentation because different editors display tabs differently. A file indented with tabs might look correct in one editor but parse differently in another. The spec requires spaces only, making the indentation unambiguous.

Why am I getting "mapping values are not allowed here"?

This error usually means: (1) a colon inside an unquoted string value — quote the value; (2) incorrect indentation mixing mappings and sequences; (3) a duplicate key on the same level. The formatter normalizes spacing but cannot fix structural logic errors — use the YAML Validator for deeper diagnosis.

Does formatting change the meaning of my YAML?

Normalization of whitespace (indentation, spaces after colons) does not change the parsed data structure. However, reordering keys or changing quoting style could technically affect tools that depend on key order. This formatter only normalizes whitespace and does not reorder keys.

Related Tools