YAML Formatter
Format and validate YAML documents. Convert between YAML and JSON effortlessly, all in your browser.
How do I use YAML Formatter?
Paste your Kubernetes manifest, Docker Compose file, or GitHub Actions YAML into the editor, or click 'Sample'.
Choose your indentation width (2 Spaces or 4 Spaces), enable Sort Keys if desired, or switch to 'To JSON' mode.
Inspect any YAML 1.2 indentation or tab errors with exact line numbers, then copy the normalized output.
What features does YAML Formatter offer?
Format and validate YAML syntax
Bidirectional YAML ↔ JSON conversion
Indentation and sorting controls
100% client-side local browser processing
YAML 1.2 Specification, Indentation Rules & The 'Norway Problem'
YAML relies on spaces (never hard tabs) for hierarchy and differentiates between YAML 1.1 and YAML 1.2 scalar type coercion rules.
| YAML Construct | Syntax Token | Newline / Escape Behavior | Typical DevOps Use Case |
|---|---|---|---|
| Literal Block Scalar | | (Pipe) | Preserves internal newlines; clip/strip trailing via |- or |+ | Embedded bash scripts in GitHub Actions |
| Folded Block Scalar | > (Greater-than) | Folds single newlines into spaces | Long multi-line descriptions in K8s |
| Anchor & Alias | &base / *base | Reuses a node reference across mappings | DRY environment blocks in docker-compose.yml |
| Quoted Scalars | "22:20" or 'NO' | Forces string type; prevents sexagesimal/boolean coercion | Country codes ('NO') & port mappings |
Frequently Asked Questions about YAML Formatter
Why does YAML throw a syntax error when I indent with the Tab key?
The YAML 1.2 specification strictly forbids hard tab characters (`\t`) for structural indentation because different editors render tab stops at different widths (2, 4, or 8 spaces). Always indent YAML with spaces.
What is the YAML 'Norway Problem' (`NO: false`) and how does YAML 1.2 fix it?
Under legacy YAML 1.1, unquoted strings like `no`, `yes`, `on`, and `off` were coerced into booleans, turning Norway's ISO country code `NO` into `false`. Our `js-yaml` YAML 1.2 engine only treats `true` and `false` as booleans, though quoting `'NO'` remains best practice.
How are YAML anchors (`&`) and aliases (`*`) handled when converting YAML to JSON?
Because JSON has no native pointer syntax, converting YAML to JSON automatically dereferences and expands all `*alias` nodes inline with the full content of their target `&anchor`.
What is the difference between `|` and `|-` in multi-line YAML strings?
The pipe `|` (literal clip) keeps a single trailing newline at the end of the block, whereas `|-` (literal strip) removes all trailing newlines—which is critical for Kubernetes Secret values and CI tokens.
Explore Related YAML Tools
JSON Formatter
Format, validate, and minify JSON data instantly. Detect syntax errors with precise line and column information.
CSV ↔ JSON
Convert between CSV and JSON formats with PapaParse engine. Auto-detection and dynamic typing.
CSV to JSON Converter
Convert CSV spreadsheets and delimited text into structured JSON arrays with auto-delimiter and dynamic data type detection.
JSON to CSV Converter
Convert JSON object arrays into RFC 4180 compliant CSV spreadsheets ready for Excel, Google Sheets, and SQL imports.
XML Formatter
Format, validate, and minify XML documents. Powered by xml-formatter for robust processing.
cURL to Python Requests Converter
Convert cURL commands with Bearer tokens, custom headers, and JSON payloads into clean Python requests code locally in your browser.