How to use the yaml validator
- Paste or type your YAML content into the text area above.
- The yaml validator checks the syntax automatically as you type.
- If the document is valid, review the summary showing the document type and key count.
- If an error is found, note the reported line number, column and description to fix it.
How the validation works
This tool uses a hand-written recursive descent parser that implements a practical subset of the YAML 1.2 specification. When you paste text, the parser splits it into lines, measures leading spaces to build an indentation stack, and reads tokens such as mapping keys, sequence dashes, flow brackets and scalar values.
If the parser encounters a structural violation, for example a key indented deeper than expected without a parent block, it stops immediately and returns the exact line and column where the problem begins. A valid document produces a short summary: whether the root is a mapping or sequence, how many top-level entries it contains, and confirmation that no syntax errors were found.
Supported YAML features
The validator covers the constructs used in most configuration files:
- Block mappings (
key: value) at any nesting depth. - Block sequences (
- item) including nested lists inside mappings. - Flow collections using square brackets
[a, b]and curly braces{x: 1}. - Plain, single-quoted and double-quoted scalars.
- Block scalars introduced by
|(literal) or>(folded). - Comments starting with
#.
Features outside this subset produce an explicit error message rather than a silently wrong parse. Anchors (&name), aliases (*name), tags (!!str) and merge keys (<<) are flagged as unsupported. Multi-document streams separated by --- are also rejected, and so are duplicate mapping keys (the YAML specification says keys must be unique) and tab characters used for indentation. The validator checks syntax only: it does not check types, schemas or tool-specific rules such as Kubernetes or Docker Compose fields. If you need to convert validated YAML to another format, tools like yaml-to-json or yaml-to-xml can help once your syntax is correct.
Common YAML mistakes
Even experienced developers hit a few recurring pitfalls when writing YAML by hand:
| Mistake | Why it fails | Fix |
|---|---|---|
| Tabs for indentation | YAML requires spaces only | Replace tabs with 2 or 4 spaces |
| Missing space after colon | key:value is read as a plain scalar | Write key: value |
| Inconsistent indent levels | Parser cannot determine nesting | Align child blocks uniformly |
| Unquoted special characters | Colons, hashes or brackets confuse the scanner | Wrap the value in quotes |
Catching these early saves time before deployment. Running your file through a yaml validator before committing it prevents broken pipelines caused by subtle whitespace issues.
When to use a yaml validator
Configuration files for CI/CD pipelines, container orchestration platforms and static site generators are frequently written in YAML. A single misplaced space can cause a deployment to fail silently or crash at startup. Validating your files locally before pushing them ensures that syntax errors are caught immediately.
This is especially useful when editing large files manually or merging changes from multiple contributors. Because the validation happens entirely in your browser, sensitive configuration data never leaves your machine. For broader style and convention checks, consider pairing this tool with a dedicated yaml lint utility. To clean up spacing after fixing errors, a yaml formatter can standardize your indentation.
Understanding the error report
When the parser finds invalid syntax, it returns three pieces of information: the line number, the column number and a plain-English description. Line and column numbers start at 1, matching what most text editors display in their status bar.
For example, if you write a mapping key indented under a sibling instead of a parent, the error points to the first character of that unexpected key. The description explains what the parser expected versus what it found. Use your editor's "Go to Line" feature to jump directly to the reported position, correct the indentation or missing punctuation, and the document should pass validation on the next attempt.
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple mapping | YAML input: name: Alice / age: 30 / active: true | Status: Valid; Document type: mapping; Top-level keys: 3 |
| Nested sequence | YAML input: fruits: / - apple / - banana / - cherry | Status: Valid; Document type: mapping; Top-level keys: 1 |
| Invalid indentation | YAML input: key: value / bad: indent | Status: Invalid; Error line: 2; Error column: 3; Description: A mapping value is not allowed here (check the indentation) |
| Flow collection | YAML input: items: [1, 2, 3] / meta: {a: 1, b: 2} | Status: Valid; Document type: mapping; Top-level keys: 2 |
FAQ
Does this yaml validator upload my data?
No. All parsing and validation happen locally in your browser. Your YAML text is never sent to any server.
What YAML version does this tool support?
It implements a practical subset of YAML 1.2, covering block mappings, sequences, flow collections, quoted scalars, block scalars and comments.
Why does my valid-looking YAML show an error?
Common causes include using tabs instead of spaces, omitting the space after a colon, or using advanced features like anchors and tags which this subset parser intentionally flags as unsupported.
Can I validate multiple YAML documents at once?
No. Multi-document streams separated by --- are not supported. Paste one document at a time for accurate validation.
How do I fix the reported error?
Use the line and column numbers to locate the issue in your text editor. The error description explains what went wrong, such as unexpected indentation or a missing closing bracket.
Is this the same as a linter?
Not exactly. This tool checks syntax validity. A linter like yaml lint also enforces style conventions such as consistent quoting and key ordering.