Skip to content
ToolZone

YAML Formatter

Validate and reformat YAML configuration files consistently, helping catch the indentation errors that are a common source of YAML parsing failures.

Runs in your browser. Nothing you enter or upload leaves your device.

Indent

Parsed with a full YAML 1.2 parser in your browser. Formatting keeps comments, anchors and multiple documents (---).

Keyboard shortcuts

Run the main action
⌘ / Ctrl + Enter
Copy the result
⌘ / Ctrl + Shift + Enter
Download the result
⌘ / Ctrl + S
Paste a file or image into file tools
⌘ / Ctrl + V
Search all tools
⌘ / Ctrl + K
Show these shortcuts
?

You can also drop files anywhere on the page.

About the YAML Formatter

This YAML Formatter parses your YAML with a full YAML 1.2 parser. It points to the exact line and column of any syntax error, re-indents valid YAML while keeping comments and anchors, and converts YAML to JSON or JSON to YAML for Docker Compose files, Kubernetes manifests and CI pipelines.

How it works

Your input is parsed with the open-source yaml library, which follows the YAML 1.2 specification. Every document in the file (separated by ---) is parsed, and the first error found is reported with its line and column, along with the surrounding lines.

Format mode prints each parsed document back out with consistent indentation, keeping comments, anchors and aliases. YAML → JSON resolves anchors and outputs JSON (an array when there are several documents), and JSON → YAML parses JSON and writes it as block-style YAML.

How to use

  1. 1

    Choose Format YAML, YAML → JSON or JSON → YAML.

  2. 2

    Paste your input or open a file, and pick 2 or 4 space indentation.

  3. 3

    If there's an error, fix the line shown; otherwise read the formatted output.

  4. 4

    Copy or download the result, or click Replace input to keep the formatted YAML.

Worked examples

Reformat four-space YAML

A config indented with four spaces.

Input
server: host: localhost port: 8080
Result
server: host: localhost port: 8080

Tab indentation

A key indented with a tab character.

Input
server: port: 8080
Result
Line 2, column 1: Tabs are not allowed as indentation

YAML forbids tabs for indentation, so the parser stops at that line.

Limitations
Only the first error is reported; fix it and the next one appears. Formatting keeps flow-style collections such as [1, 2] as they are rather than converting them to block lists. It checks YAML syntax, not a schema, so a valid file can still have wrong keys for Kubernetes or Compose.
Assumptions
The input follows YAML 1.2.
Privacy
The check runs in your browser and your YAML is not sent anywhere.

Frequently asked questions

Why is YAML so sensitive to indentation?+

YAML uses indentation instead of brackets or tags to show nesting, so a few extra or missing spaces can change the meaning of a file or make it fail to load.

Can I use tabs in YAML?+

No. The YAML specification does not allow tabs for indentation, and this tool reports any tab used as indentation with its line number.

Does this tool reformat my YAML?+

Yes. Format YAML re-indents every document to 2 or 4 spaces and keeps your comments.

Is four-space YAML valid?+

It isn't. Four-space YAML is valid; the formatter can convert it to two spaces if you choose.

Does "Valid YAML" mean my file will load?+

Yes, as far as syntax goes: the file is parsed with a full YAML parser. It doesn't check the keys against a schema such as Kubernetes or Compose.

Related tools