YAML Formatter
Format, validate, and convert YAML documents with syntax highlighting and error detection
YAML Input
Formatted Output
Inspector
Advanced Options
Compare with another YAML
Send this document to Data Diff and paste a second version to see what changed.
Validation with the exact error position
Validation runs on every keystroke using the js-yaml 1.2 parser. Valid documents get live counts of documents, mappings, sequences, keys and depth. Broken ones report the exact line and column, a probable cause, and a highlight at the failing position — not just "syntax error".
Common YAML errors this tool pinpoints
These mistakes account for most invalid YAML. Each one is detected with a position and a probable cause:
Bad indentation
A child line indented less than its parent, or siblings that do not align. Usually reported as "bad indentation of a mapping entry" at the exact line.
TAB character
YAML forbids tabs in indentation. The parser reports "found a tab character that violates indentation" and highlights the offending line.
Duplicate key
The same key twice in one mapping. js-yaml reports "duplicated mapping key" with the line of the second occurrence.
Missing colon or space
A key without a value ("key key2") or a colon glued to the key ("key:value" is a plain string, not a pair). Reported as "could not find expected ':'".
Before / After
Minified Kubernetes manifest on the left, the same document formatted with 2-space indent on the right. Structure, tree and paths update from the parsed document.
{apiVersion: apps/v1, kind: Deployment, metadata: {name: web-app}, spec: {replicas: 3, template: {metadata: {labels: {app: web}}}}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app
spec:
replicas: 3
template:
metadata:
labels:
app: web
YAML quick reference (YAML 1.2)
- Indentation is structure: spaces only — TAB characters are never allowed for indentation.
- A colon must be followed by a space to be a key separator: "key: value", not "key:value".
- Scalars resolve to types by the core schema: true/false (booleans), integers, floats, null (~ / null / empty). Note "yes"/"no" are plain strings in 1.2.
- Multiple documents in one file are separated by a "---" line; "..." ends a document.
- Anchors (&base) and aliases (*base) keep files DRY; merge keys ("<<: *base") inherit mappings.
Next steps with this data
Formatting is the first step. Continue the workflow without leaving your browser:
Frequently Asked Questions
Common questions about Yaml Formatter formatting answered
The formatter follows the YAML 1.2 specification, ensuring compatibility with modern tools like Kubernetes, Docker Compose, GitHub Actions, and other cloud-native platforms.
Yes, the bidirectional conversion feature lets you convert YAML to JSON and JSON to YAML while preserving data types, nested structures, and comments where applicable.
Absolutely. The formatter is designed to handle Kubernetes manifests, Docker Compose files, CI/CD pipelines, and other multi-document YAML files with proper section separation.
The validator checks indentation consistency, proper use of colons and dashes, quoted string balance, anchor and alias references, and provides line-specific error messages for quick debugging.
Yes, the formatter correctly handles YAML anchors (&), aliases (*), and merge keys (<<), preserving these DRY features while formatting the surrounding structure.
YAML 1.2, the current spec from yaml.org - the version Kubernetes, docker-compose, and GitHub Actions documents target. YAML 1.2 made JSON a valid subset and tightened boolean parsing; the formatter keeps your quoting explicit where 1.1 parsers (still common in Python PyYAML) would misread values like "no" or "0777".
YAML anchors, aliases, and block scalars carry comments through unchanged, but a comment attached to a key that gets re-indented moves with its indentation level. The formatter never deletes comments - it relocates them minimally to stay attached to the node they document.
It flags it: bare NO, no, ON, on, yes, n are quoted automatically during formatting, so YAML 1.1 parsers cannot coerce them to booleans. The country-code list [NO, SE, DK] stays three strings. YAML 1.2 only treats true/false as booleans, but quoting is the only output that is safe under both versions.
Authoritative References
Standards and official documentation that define the formats this tool works with.
Related Tools
JSON Formatter
Format, validate, and beautify JSON data with intelligent indentation and syntax highlighting
JSON Repair
Fix malformed, invalid, or broken JSON instantly. Repair truncated LLM output, missing commas, unquoted keys, and trailing commas in your browser
JSONL Formatter
Format JSON Lines (NDJSON) files and convert between JSON and JSONL. Validate each line and pretty-print NDJSON streams