YAML Formatter / Validator

Format and validate YAML documents.

Open tool

Overview

The YAML formatter parses, validates, and pretty-prints a YAML document. Indentation is normalised to a consistent width, scalar quoting is applied where YAML's type rules would otherwise produce surprises, and parse errors are reported with line and column.

YAML is the lingua franca of modern config — Kubernetes manifests, GitHub Actions workflows, Helm values, OpenAPI specs. Developers, DevOps engineers, and platform teams use a yaml validator to confirm a hand-edited file parses and reads cleanly before committing.

How it works

The formatter follows YAML 1.2, the current stable spec. Parsing handles block and flow styles, anchors and aliases, multi-document streams (--- separators), and the full scalar type system. Errors are reported with location — common ones include incorrect indentation, mixing tabs with spaces, and unquoted strings that match the "Norway problem" booleans (no, off, false).

When re-emitting, the formatter chooses the safest scalar style: plain scalars where unambiguous, double-quoted where the content might be misinterpreted ("yes", "1.0", "null"), and literal block (|) for multi-line strings where newlines matter. Indentation defaults to two spaces.

Examples

Input (inconsistent):
name:    Alice
age:30
tags: [admin,ops]
Output:
name: Alice
age: 30
tags:
  - admin
  - ops
Validation result:
ERROR line 4: mapping values are not allowed in this context

FAQ

What's the "Norway problem"?

YAML 1.1 treated no, yes, on, off, true, false, and a few others as booleans. A country code NO (Norway) would silently become false. YAML 1.2 narrows this list, but legacy parsers still trip up. The formatter quotes risky strings automatically.

Does it support multi-document streams?

Yes. Files with multiple ----separated documents are parsed independently; each is formatted and re-joined with the separator. That's the shape Kubernetes uses for kubectl apply with multiple resources in one file.

Can it produce flow style instead of block style?

Block style (key: value on separate lines) is the default since it's the readable convention. Flow style ({ key: value, ... }) is opt-in for compact one-line maps and arrays.

Try YAML Formatter / Validator

An unhandled error has occurred. Reload ×