YAML Validator - Check Syntax & Convert to JSON

Validate YAML syntax, find errors, and convert to JSON

Validate YAML

Paste your YAML below to check for syntax errors. Works with Docker Compose, Kubernetes manifests, GitHub Actions, Ansible playbooks, and any YAML file.

YAML Syntax Quick Reference

Common YAML structures you'll encounter in configuration files:

Key-Value Pairs

name: my-app version: "1.0" enabled: true

Nested Objects

database: host: localhost port: 5432

Lists (Arrays)

ports: - 80 - 443 - 8080

Inline Lists

tags: [web, api, v2] ports: [80, 443]

Multi-line Strings

description: | This is a long multi-line text block.

Comments

# This is a comment name: app # inline

Example YAML Files

Click "Load" to try validating these common configuration formats:

🐳 Docker Compose

version: '3.8'
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./html:/usr/share/nginx/html
  db:
    image: postgres:15
    environment:
      POSTGRES_PASSWORD: secret

☸️ Kubernetes Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.25

⚙️ GitHub Actions

name: CI
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run tests
        run: npm test

📦 package.yaml (Helm)

apiVersion: v2
name: my-chart
description: A Helm chart
type: application
version: 0.1.0
appVersion: "1.0.0"
dependencies:
  - name: postgresql
    version: "12.x.x"
    repository: https://charts.bitnami.com

Common YAML Errors and Fixes

These are the most frequent YAML syntax errors and how to resolve them:

Error Problem Fix
bad indentation Inconsistent spacing or mixed tabs/spaces Use exactly 2 spaces per indent level. Never use tabs.
mapping values are not allowed Missing space after colon Add space: key: value not key:value
unexpected end of stream Unclosed quotes or brackets Ensure all " ' [ { are closed
duplicate key Same key appears twice at same level Remove or rename the duplicate key
can not read a block mapping List item used where object expected Check if - should be a key-value pair instead
Unexpected boolean/number Values like yes, no, on, off become booleans Quote strings: "yes" or 'no'

Understanding YAML

What is YAML?

YAML (YAML Ain't Markup Language) is a human-readable data serialization format. Unlike JSON or XML, YAML uses indentation to represent structure, making it easier to read and write by hand. It's the standard format for configuration files in modern DevOps and cloud-native tooling.

Where is YAML Used?

  • Docker Compose: Define multi-container applications (docker-compose.yml)
  • Kubernetes: Deployments, Services, ConfigMaps, and all K8s resources
  • GitHub Actions: CI/CD workflow definitions (.github/workflows/*.yml)
  • GitLab CI: Pipeline configurations (.gitlab-ci.yml)
  • Ansible: Playbooks and inventory files
  • Helm: Kubernetes package manager charts
  • CloudFormation: AWS infrastructure as code
  • OpenAPI/Swagger: API specifications

YAML vs JSON

YAML is a superset of JSON—any valid JSON is also valid YAML. Key differences:

  • Readability: YAML uses indentation; JSON uses braces and brackets
  • Comments: YAML supports comments (# comment); JSON does not
  • Quotes: YAML strings often don't need quotes; JSON always requires double quotes
  • File size: YAML files are typically smaller due to less punctuation
  • Multi-line: YAML has native multi-line string support (| and >)

YAML Indentation Rules

Indentation defines structure in YAML. Follow these rules to avoid errors:

  • Use spaces only—never tabs
  • Be consistent: pick 2 spaces (most common) and stick with it
  • Child elements must be indented more than their parent
  • Sibling elements must have the same indentation

Frequently Asked Questions

How do I validate YAML syntax?

Paste your YAML into the validator above and click "Validate." The tool parses your YAML and shows either a success message or a detailed error with the line number and problem description. You can also convert valid YAML to JSON to verify the structure matches your expectations.

What causes "bad indentation" errors?

YAML is strict about indentation. This error occurs when lines have inconsistent spacing or mix tabs with spaces. To fix it: use only spaces (never tabs), use the same number of spaces per indent level (2 is standard), and ensure child elements are indented more than their parents.

Why do I get "mapping values are not allowed here"?

This usually means you forgot a space after a colon. In YAML, key-value pairs need a space: key: value is correct, but key:value causes this error. It can also occur when indentation is wrong, making the parser think a value is a new mapping.

How do I write multi-line strings in YAML?

Use the pipe character (|) to preserve line breaks, or the greater-than symbol (>) to fold lines into a single line. Example:

description: |
  This text preserves
  line breaks exactly.

summary: >
  This text gets folded
  into a single line.

Why does "yes" become true in YAML?

YAML automatically converts certain words to booleans: yes, no, true, false, on, off. If you need the literal string "yes", wrap it in quotes: "yes" or 'yes'. The same applies to values that look like numbers or dates.

Can I convert YAML to JSON?

Yes. Click "Convert to JSON" above to transform your YAML into equivalent JSON. Since YAML is a superset of JSON, any valid YAML can be represented as JSON (though comments are lost in conversion).

What's the difference between .yaml and .yml?

Nothing—they're interchangeable. .yaml is the official extension recommended by yaml.org, but .yml is widely used for brevity. Both are recognized by all YAML parsers. Choose one and be consistent in your project.

Privacy & Limitations

  • All calculations run entirely in your browser -- nothing is sent to any server.
  • Results are computed locally and should be verified for critical applications.

Related Tools

  • UUID Bulk Generator -- Generate large batches of UUID v4 or v7 values with export-ready formatting
  • JSON Formatter -- Format and beautify JSON with proper indentation
  • CSS Formatter -- Format CSS with proper indentation
  • Color Picker -- Visual color picker with HEX, RGB, HSL conversion and color harmonies

Related Tools

View all tools

YAML Validator FAQ

What is YAML?

YAML (YAML Ain't Markup Language) is a human-readable data serialization format used for configuration files. It uses indentation to represent structure and is commonly used in DevOps tools like Docker Compose, Kubernetes, Ansible, and GitHub Actions.

How do I validate YAML syntax?

Paste your YAML into a validator tool and click validate. The validator will parse the YAML and report any syntax errors, including the line number and type of error. Common errors include incorrect indentation, missing colons, and improper quoting.

What is the difference between YAML and JSON?

YAML uses indentation and is more human-readable, while JSON uses braces and brackets. YAML supports comments (lines starting with

Why does indentation matter in YAML?

YAML uses indentation to define structure and nesting. Unlike JSON which uses braces, YAML relies on consistent spacing (typically 2 spaces) to show hierarchy. Mixing tabs and spaces or inconsistent indentation causes parsing errors.

Request a New Tool
Improve This Tool