YAML Formatter & Validator
Tidy up messy YAML and find syntax errors with their line and column. You can also sort keys and expand inline {a: 1} style into block style. To convert to JSON, use the YAML ⇔ JSON Converter.
🔒 Runs in your browser · Your data is never sent to a server
Notes
- Comments are kept, but their position and spacing may be adjusted to fit the formatted layout.
- Long strings are not wrapped; they stay on a single line.
- "Sort keys alphabetically" applies to nested maps too. The order of list items is never changed.
- Multiple documents are separated with "---". A map that contains the same key twice is reported as an error.
- Anchors (&) and aliases (*) are kept as written, not expanded. The check covers YAML syntax only; it does not validate against a schema.
Glossary
Block style vs. flow style
Block style shows structure with line breaks and indentation; flow style writes it inline with brackets, such as {a: 1} or [x, y].
Anchor and alias
An anchor (&name) labels a value and an alias (*name) reuses it elsewhere, which cuts repetition in config files.
Multiple documents
One file can hold several YAML documents separated by "---", as is common in Kubernetes manifests.
FAQ
Why does a tab in my indentation cause an error?
The YAML spec allows only spaces for indentation, so tabs are a syntax error. The tool reports the line and column, so replace the tab with spaces. The output indent can be 2 or 4 spaces.
Does formatting change my comments or values?
Comments are kept and keys and values are not altered. Spacing in inline forms like {a: 1}, quoting style, and blank lines may be normalized. The meaning of the YAML stays the same, but it is still worth reviewing the diff for config files.
Why is a duplicate key reported as an error?
Keys in a YAML map are supposed to be unique, and some parsers silently let the later value overwrite the earlier one. To catch accidental mistakes, duplicate keys are reported with their line and column.
Can it format YAML with multiple documents?
Yes. Each document separated by --- is formatted and the results are joined with ---. If one of them has an error, the message tells you which document and which line.
Share this page
