YAML Formatter & Validator
Validate and re-indent YAML while keeping comments, anchors and tags. Syntax errors point to the exact line and column.
YAML Formatter & Validator: the tool
Input
Formatted YAML
The result appears here.How to use YAML Formatter
- Paste YAML into the left panel, or press Example to load a configuration with uneven indentation.
- The formatted result appears on the right. Choose 2 or 4 spaces, and whether list items are indented under their key.
- Turn on Sort keys to order the keys of every mapping alphabetically. Comments move with their entries.
- If the YAML is invalid, the status bar gives the line and column. Press Go to error to jump to it.
Example
A configuration with irregular indentation and a flow mapping, formatted with 2 spaces. The comment is kept.
# Service configuration
name: codevory
server:
host: localhost
port: 8080
features:
- json
- yaml
limits: {maxMb: 10, ratio: 0.5}# Service configuration
name: codevory
server:
host: localhost
port: 8080
features:
- json
- yaml
limits: { maxMb: 10, ratio: 0.5 }About this tool
YAML uses indentation to express structure, so one misplaced space changes the meaning, and tabs are not allowed at all. The formatter parses the document with a YAML 1.2 parser, reports the first error, and prints the same data with consistent indentation. Comments, anchors (&name), aliases (*name), tags and block scalars are preserved.
Long text values are never rewrapped unless you turn on Wrap long lines, so a formatted file does not change line by line in a way that would clutter a diff. Documents separated by --- are formatted one by one. Duplicate keys in a mapping are treated as errors, as the YAML specification requires.
The data does not change when you format. A folded block (>) may be laid out on fewer lines, but its value is identical. Everything runs in your browser, so configuration files that contain internal names or secrets are not uploaded.
Common YAML mistakes
| Mistake | Why it fails | Fix |
|---|---|---|
| Tab indentation | Tabs are not allowed to indent | Use spaces |
| Mixed indentation levels | Siblings must start in the same column | Align all keys of a mapping |
| Duplicate key | Keys in a mapping must be unique | Rename or remove one |
| Unquoted colon in text (a: b: c) | A second colon starts a nested mapping | Quote the text: a: "b: c" |
| Unclosed [ or { | Flow collections must be closed | Add the closing bracket |
Frequently asked questions
Are comments preserved when formatting YAML?
Yes. Comments are kept with the entries they belong to, including end-of-line comments, and they move along when you sort keys.
Why is yes or no not converted to true or false?
This tool follows YAML 1.2, where only true and false are booleans. In YAML 1.1, which older tools use, yes, no, on and off were booleans too, which famously turned the country code NO (Norway) into false. Quote the value if another tool needs a specific reading.
Does formatting change the data?
No. Mappings, lists and scalars keep their values. Only layout changes: indentation, spacing, and how some block scalars are laid out.
Does it support multiple documents in one file?
Yes. Documents separated by --- are all validated and formatted, and the separators are kept.
Can YAML use tabs?
Not for indentation. A tab can appear inside a value, but using one to indent a line is an error, and the message points at the line.
More developer tools
- yml→YAML to JSON ConverterConvert YAML to JSON, resolving anchors, aliases and merge keys. Big integers stay exact and key order is preserved.
- { }JSON Formatter & ValidatorFormat, validate and minify JSON. Errors point to the exact line and column, and nothing you paste leaves your browser.
- <x>XML FormatterBeautify or minify XML after checking that it is well-formed. Mixed content, CDATA and comments are kept intact.
- ok?JSON ValidatorCheck JSON against the specification and get the exact line and column of the first error, plus a summary of what the document contains.