YAML Validator

Check YAML syntax and find errors.

Local Your input is processed locally in your browser. The first run loads the open-source js-yaml library from this site; your input is not sent anywhere. Found a problem? Report an issue

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: London

Output

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.10 is the number 1.1 and an unquoted 2024-01-05 is 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 symptomWhat it means
bad indentation of a mapping entryItems at the same level must line up exactly, using spaces only.
tab characters must not be used in indentationReplace tabs with spaces.
duplicated mapping keyThe same key appears twice in one mapping.
A value that turns into something unexpectedQuote 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: (where name starts 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 with helm template or 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.