What the YAML Validator does
The YAML Validator parses a YAML document with the js-yaml library and reports indentation, tab and duplicate-key errors with their line and column. It answers whether the file can be loaded; it does not check it against the schema of Kubernetes, a CI system or any other consumer.
YAML Validator example
The built-in sample
Input
name: Ada
tags:
- math
- code
address:
city: LondonOutput
Valid YAML.This is the input that the Load sample button fills in.
Each output was produced by running this tool on the input above it.
How it works
js-yaml parses the input and reports errors with a line and column. If parsing succeeds, the tool answers "Valid YAML."
Details and limits
- One document per check: a stream with several documents separated by
---is reported as "expected a single document in the stream". - Valid YAML can still mean something you did not intend.
version: 1.10is the number 1.1 and an unquoted2024-01-05is a timestamp. Use YAML to JSON to see the values as they are parsed. - The error message includes a short excerpt of the lines around the problem with a marker under the column.
Common errors
| Message or symptom | What it means |
|---|---|
| bad indentation of a mapping entry | Items at the same level must line up exactly, using spaces only. |
| tab characters must not be used in indentation | Replace tabs with spaces. |
| duplicated mapping key | The same key appears twice in one mapping. |
| A value that turns into something unexpected | Quote values such as 1.10, 0123 or yes/no if they must stay text. |
Worked example: Diagnosing an unquoted colon and bad indentation in a GitHub Actions workflow
Suppose your CI pipeline refuses to start on this 7-line .github/workflows/ci.yml snippet:
1: name: Nightly QA Suite
2: on: [push]
3: jobs:
4: test:
5: runs-on: ubuntu-latest
6: steps:
7: - name: Run Playwright: Chromium headless
8: run: npx playwright test
- Error 1 on Line 7 (
Run Playwright: Chromium headless): In YAML, a colon followed by a space (:) inside an unquoted string starts a new nested key-value mapping! Wrap any string containing:in double or single quotes:- name: "Run Playwright: Chromium headless". - Error 2 on Line 8 (
run:indented by 7 spaces instead of 8): Under- name:(wherenamestarts at Column 9), sibling keys of the same list item (run:) must align vertically at Column 9 (8 spaces).
Limits and what this tool cannot do
- Reports the first structural syntax error: Because indentation in YAML defines the nesting tree for all subsequent lines, a single broken indentation level or unclosed quote on Line 10 cascades into downstream lines. Fix the reported line and click Validate again.
- Does not validate Helm Go-templates (
{{ .Values.image }}): Unrendered Helm chart templates containing raw{{ ... }}curly braces are not valid YAML until rendered withhelm templateor wrapped in quotes.
Questions
Why is my Kubernetes file reported as invalid?
Manifests often contain several documents separated by ---. This validator accepts one document at a time, so check each part separately.
When do I have to put quotes around a string in YAML?
Always quote strings that contain a colon followed by a space (: ), start with special YAML indicators (#, @, &, *, !, %, {, [, >, |), or look like numbers/booleans when you want a string (such as version "3.10", port range "80:80", or country code "NO").
What is the difference between | (literal block) and > (folded block) for multi-line strings?
A pipe (|) preserves every newline character inside the indented block (ideal for shell scripts in run: |). A greater-than sign (>) folds single newlines into spaces so a long paragraph wraps nicely in your editor.
Are my YAML secrets or kubeconfig files uploaded anywhere?
No. Validation happens 100% locally in your browser's JavaScript runtime.