tool

YAML Formatter & Validator

Fix messy indentation, catch tabs and unclosed brackets, and tidy config files for Docker, Kubernetes and CI.

input
0 characters
1
result

paste your code and choose format

Validate and format YAML config files

YAML runs a huge amount of modern infrastructure: Docker Compose files, Kubernetes manifests, GitHub Actions and GitLab CI pipelines, Ansible playbooks, OpenAPI specs and countless app configs. It's also easy to break with one wrong indent. Paste your YAML to check it for syntax errors, including tabs, inconsistent indentation, misplaced list items and unclosed brackets, and to re-format it with clean, two-space indentation. Comments, anchors and multi-document files are preserved, and the YAML never leaves your browser.

What can you do?

  1. 1. Find YAML syntax errors
    Get the line and column of the first problem, such as “Line 4, column 1: All mapping items must start at the same column” or “Tabs are not allowed as indentation”.
  2. 2. Re-indent consistently
    Normalise nested maps and lists to two-space indentation, tidy spacing after colons and in flow collections like [ "3000:3000" ].
  3. 3. Keep comments and structure
    Comments stay where they are, and anchors (&base), aliases (*base), merge keys (<<) and block scalars (| and >) are kept intact.
  4. 4. Multi-document support
    Files containing several documents separated by --- (common in Kubernetes manifests) are validated and formatted document by document.

Why validate YAML before you deploy?

In YAML, indentation is structure. A key that is one space off becomes part of a different object, or makes the whole file invalid, and the error message from a deployment tool often points somewhere else entirely. Tabs are not allowed for indentation at all, yet many editors insert them.

Checking the file before you commit or apply it turns a failed pipeline or a crash-looping container into a ten-second fix. Formatting it consistently also makes reviews and diffs much easier to read.

How to validate a YAML file

  1. 1. Paste the YAML
    Paste a docker-compose.yml, a Kubernetes manifest, a workflow file or any other YAML document.
  2. 2. Click validate
    If the YAML is valid you'll see a success message; if not, the first error is shown with its line and column.
  3. 3. Fix and repeat
    Correct the reported line and validate again until the file passes.
  4. 4. Format if you like
    Click format for consistently indented output, then copy it back into your repository.

Example: fixing a docker-compose.yml

This Compose file uses four-space indentation, single quotes and extra spaces. After formatting it uses two spaces, double quotes and tidy flow lists, and the comment is preserved:

YAMLInput
services:
    web:
        image: 'node:22-alpine'
        ports: [ "3000:3000" ]
        environment:
            NODE_ENV:    production   # runtime
    db:
        image: postgres:16
YAMLFormatted
services:
  web:
    image: "node:22-alpine"
    ports: ["3000:3000"]
    environment:
      NODE_ENV: production # runtime
  db:
    image: postgres:16

Common YAML errors and how to fix them

Frequent YAML syntax errors with causes and fixes
Error messageTypical causeFix
All mapping items must start at the same columnSibling keys indented by different amountsLine up sibling keys at exactly the same column
A block sequence may not be used as an implicit map keyA list item (- x) indented less than the items above itIndent every item of a list by the same amount
Tabs are not allowed as indentationA tab used for indentationReplace tabs with spaces
Flow sequence in block collection must be sufficiently indented and end with a ]An unclosed [ listAdd the missing ]
Nested mappings are not allowed in compact mappingsA value like key: other: value on one lineQuote the value or move it to its own indented line

YAML gotchas a validator can't catch

Some YAML is perfectly valid but doesn't mean what you think. Watch for these in config files:

  • Duplicate keys
    A key that appears twice in the same mapping is accepted by the formatter, and many YAML parsers silently keep only the last value. Search for repeated keys when a setting seems to be ignored.
  • Unquoted values that change type
    Under YAML 1.1 rules, still used by many tools, NO, off and yes become booleans, and a version like 3.10 is the number 3.1. Quote values such as country codes and versions: "NO", "3.10".
  • Port mappings and times
    Docker's documentation recommends quoting port mappings like "22:22", because unquoted colon-separated numbers can be read as base-60 numbers by YAML 1.1 parsers.
  • Schema errors
    A misspelled Kubernetes field or a GitHub Actions key in the wrong place is valid YAML. Use the platform's own schema validation (kubectl --dry-run, actionlint, docker compose config) for those.

Frequently asked questions

Does formatting change my data?

No. Values, keys and their order stay the same. The formatter changes indentation, spacing and quote style (preferring double quotes), and keeps comments.

Can I convert YAML to JSON here?

Not with this tool, which formats and validates YAML only. If you already have JSON, the JSON formatter can validate and pretty-print it.

Is .yml different from .yaml?

No. Both extensions are the same format. Docker Compose, GitHub Actions and most tools accept either.

Why can't I use tabs?

The YAML specification forbids tab characters for indentation to avoid ambiguity between editors with different tab widths. Configure your editor to insert spaces in .yml and .yaml files.

Is it safe to paste files that contain secrets?

The YAML is processed in your browser and isn't uploaded or stored. As a good habit, still remove passwords and tokens before pasting config files into any website.

Config in JSON instead? Validate it with the JSON formatter. Comparing two versions of a manifest? Paste both into the diff checker.