Developer tools

YAML Formatter & Validator

YAML Formatter & Validator

Validate YAML with line and column errors, re-indent it and keep comments.

About this tool

About YAML Formatter & Validator

YAML breaks in quiet ways: a tab instead of spaces, a key indented one space too far, a duplicate key that silently overwrites the first one. Paste a Kubernetes manifest, a docker-compose file, a GitHub Actions workflow or an Ansible playbook and this validator tells you exactly what is wrong and where, with the line and column of the first problem. Valid YAML is re-indented consistently with 2 or 4 spaces, while your comments, anchors and aliases stay in place. You can expand inline [lists] and {maps} into block style, and sort keys alphabetically at every level when you want two files to be easy to compare. Files with several documents separated by --- are supported, and the result tells you how many documents it found. The parser follows YAML 1.2, the version used by most modern tools, and it runs in your browser, so secrets, tokens and internal hostnames in your config never leave your device. Optional AI help can repair invalid YAML or explain a config file with your own AI key, sending only that YAML straight to your provider.

Built and maintained by Abhi JainUpdated

How to Validate and Format YAML

  1. 1

    Paste or open YAML

    Paste YAML into the left pane, open a .yaml or .yml file, or click Sample.

  2. 2

    Fix any error

    If the YAML is invalid, the message under the panes gives the line, the column and the reason. Fix it and the output updates.

  3. 3

    Choose the style and copy

    Pick 2 or 4 spaces, optionally expand inline lists or sort keys, then copy or download the formatted YAML.

YAML Formatter & Validator: questions and answers

Why is my YAML invalid?

The most common causes are tabs used for indentation (YAML only allows spaces), inconsistent indentation inside a list or map, a missing space after a colon, an unquoted value containing ': ' or ' #', and duplicate keys. The error message points at the line and column where the parser gave up.

Does formatting keep my comments?

Yes, as long as Sort keys is off. Comments, anchors (&name) and aliases (*name) stay where they are. Sorting rebuilds the data from scratch, which drops comments, and the tool warns you when that happens.

Should YAML use 2 or 4 spaces?

Both are valid; YAML only requires consistency within a block. Two spaces is the convention for Kubernetes, docker-compose, GitHub Actions and most other tools, so it is the default here.

Can it validate a Kubernetes manifest?

It checks that the file is valid YAML, including multi-document files separated by ---. It does not check Kubernetes-specific fields such as apiVersion or kind against the Kubernetes schema.

Is YAML 1.1 or 1.2 used?

The parser follows YAML 1.2. The main difference is that 1.2 reads yes, no, on and off as plain text, while YAML 1.1 parsers such as PyYAML read them as booleans. Quote such values if both kinds of tools read your file.

Can AI fix invalid YAML?

Yes, if you want it. Add your own AI key in AI settings and click AI to fix the YAML (you see each change and choose whether to replace the input) or to explain the config. Only the YAML in the input is sent, from your browser to your provider, so remove secrets first.