YAML is easy to write and easy to get wrong. A tab where spaces belong, a missing space after a colon or a list item at the wrong depth can turn a working configuration into an error. This YAML validator tells you exactly where the problem is, and once the file is valid it can tidy the layout or squeeze it into flow style.
How the YAML validator works
The page uses the yaml library for JavaScript. It parses text with a parser that reports errors, and each error carries a one-indexed line and column. [1] The tool shows the first error with its position and counts any that follow. Fix the first one and run again, because later messages are often caused by the first.
Pick Validate only if you just want a yes or no. Pick Validate and format to get the cleaned text as well. Both modes show the number of documents found when the file is valid.
Formatting with 2 or 4 spaces
Valid YAML is written back out with the indent you choose. Lines are not wrapped, so long strings stay on one line. Spacing after colons, indentation of lists and quoting are normalised. Comments stay attached to their lines in this mode, which makes it suitable for tidying a file you intend to keep editing.
Flow style and YAML minify
Flow style is the compact YAML form, with braces and brackets instead of indentation. The library can force a collection style when writing and a collection can be marked as flow. [1] Choose Flow style and every document is written in that form, one line per document. It is useful for short values in a command line or a template, and it is the closest YAML has to minifying. Because the output is rebuilt from the data, comments are not carried over.
Note that flow style output of a very large document is one long line. Use it for small structures.
Several documents in one file
A YAML stream can hold several documents separated by three dashes. The library offers a call for parsing all of them, while the basic parse handles a single document. [1] This tool uses the all-documents route, so each document is checked, and the result is joined with three dashes again.
Typical errors this finds
- A flow sequence or mapping that is never closed, such as b: [1, 2 with no closing bracket.
- Duplicate keys in the same mapping.
- A tab used for indentation, which YAML does not allow.
- Inconsistent indentation inside a block.
- Block content placed inside a flow collection, which the parser reports as an error. [1]
Worked example
Paste a: 1 on one line, b: [1, 2 on the next and c: 3 after it. The validator reports an error at line 3, column 1, because the bracket on line 2 is not closed. Add the closing bracket and the file becomes valid, with the message Valid YAML (1 document). Switch to Flow style and you get { a: 1, b: [ 1, 2 ], c: 3 }.
Tips for cleaner YAML
- Use spaces only and keep one indent width through the file.
- Quote strings that could be read as numbers, booleans or null, such as yes, no or 007.
- Put a space after every colon that separates a key from its value.
- Validate before committing configuration for CI, Kubernetes or Docker Compose.
Why YAML errors are hard to spot
YAML relies on indentation and a few punctuation marks rather than closing tags, so a mistake looks small on screen but changes the structure. A list item shifted by one space can turn into part of the previous value. A colon inside an unquoted string can start a new key. Editors with syntax colouring help, but only a parser tells you for certain whether the file reads the way you meant. Running the text through this page before you deploy takes seconds and catches problems that would otherwise appear as a failed build or a service that refuses to start.
It also helps when you receive YAML from someone else. Paste it, reformat it with your own indent and the structure becomes obvious, with nested keys lined up the way you expect.
Common mistakes
- Assuming a file is fine because an editor did not complain. Run it through a parser.
- Mixing tabs and spaces when copying from another file.
- Forgetting that flow style drops comments.
- Pasting JSON and expecting an error. JSON is mostly valid YAML, so it passes and is reformatted.
What this tool does not check
It checks YAML syntax only. It does not know whether keys match the schema your application expects, so a valid file can still be a wrong configuration. For that, validate against the schema in the tool that consumes the file.
Privacy
The parser runs in your browser and nothing is uploaded, so you can safely check files that contain hostnames or internal settings. Remove real secrets from examples you share anyway.
Related tools
To convert between JSON and YAML, use the JSON to YAML converter. To format TypeScript, GraphQL or Markdown with the same page layout, try the code formatter. For JSON, use the JSON formatter and validator.
What next
Use this often? Add YAML Validat to your Home screen.
Frequently asked questions
How does this YAML validator find errors?
It parses the text with the yaml library and reports the first problem with its line and column, plus how many more follow. Fix the first one and run again, since later errors are often side effects.
What is flow style?
Flow style writes collections with braces and brackets on one line, like { a: 1, b: [ x, y ] }, instead of using indentation. It is valid YAML and handy for short values.
Does formatting keep my comments?
Validate and format keeps comments. Flow style rebuilds the document from its data, so comments are dropped.
Can it check files with several documents?
Yes. Documents separated by three dashes are parsed one by one, and the count is shown when the file is valid.
Is my YAML uploaded?
No. Checking and formatting happen in your browser, so configuration files with secrets or hostnames stay on your device.
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.