YAML Formatter
Formatters & BeautifiersFormat YAML for Kubernetes, Docker, CI configs — indent properly, validate syntax. Free, private — all processing in your browser.
The YAML Formatter beautifies YAML files with consistent indentation and spacing — essential for Kubernetes manifests, Docker Compose files, GitHub Actions workflows, GitLab CI configs, Ansible playbooks, CircleCI, and any YAML config. YAML is whitespace-sensitive, so a single misplaced space or tab can break your entire config. This formatter normalizes indentation (2 or 4 spaces, never tabs), validates that the YAML is parseable, flags common mistakes (tabs instead of spaces, inconsistent indentation, missing colons, unclosed quotes), and produces output that works in all modern YAML parsers.
YAML is the standard configuration format in modern DevOps. Kubernetes alone processes billions of YAML manifests daily. Every CI/CD tool uses YAML. Docker Compose is YAML. Helm charts are YAML templates. Homebrew, OpenAPI, Cloudformation, all use YAML. Despite its popularity, YAML has quirks (the famous "Norway problem" where NO parses as boolean false, octal number surprises, type coercion) that make hand-editing error-prone. This formatter catches many issues while making your configs readable.
YAML Formatter — key features
Normalize indentation
Convert tabs to spaces. Ensure consistent 2 or 4 space indentation per level.
Syntax validation
Checks YAML is parseable. Reports line numbers of syntax errors.
Preserves comments
# comments kept in original positions — essential for documented configs.
Multiple YAML docs
Supports --- separated multi-document YAML files (common in Kubernetes).
Block vs flow style
Preserves source style. Block (default YAML) is readable; flow (JSON-like) is compact.
Anchors and references
&anchor and *reference preserved through formatting.
Detects common issues
Flags Norway problem, octal confusion, tab indentation, trailing whitespace.
100% client-side
Your YAML (K8s manifests, CI configs with secrets) stays in browser.
How to use the YAML Formatter
- 1
Paste YAML
K8s manifest, Docker Compose, GitHub workflow, Ansible playbook, any YAML.
- 2
Set indentation
2 spaces (K8s, Docker, most modern) or 4 spaces (Ansible convention). Never tabs — YAML forbids.
- 3
Click Format
Cleanly indented YAML with consistent spacing. Errors highlighted.
- 4
Review warnings
Tool flags Norway problem values, potential type confusion, risky patterns.
- 5
Copy or download
Apply with kubectl, docker-compose, or commit to your repo.
Common use cases for the YAML Formatter
Kubernetes
- →Deployment manifests: Format Deployment, Service, Ingress, ConfigMap YAML before kubectl apply.
- →Helm chart templates: Helm values.yaml and template files — format for readability.
- →Kustomize overlays: Base + overlay YAML structures. Format each for clarity.
- →CRD definitions: Custom Resource Definitions are complex YAML — format to understand.
CI/CD
- →GitHub Actions workflows: .github/workflows/*.yml — format complex workflows for reading.
- →GitLab CI pipelines: .gitlab-ci.yml format and validate before push.
- →CircleCI config: .circleci/config.yml — long pipeline configs.
- →Azure Pipelines: azure-pipelines.yml — format before committing.
Docker
- →Docker Compose files: compose.yaml — multi-service configs.
- →Docker Swarm stacks: Stack YAML for Docker Swarm.
- →Docker buildx bake: docker-bake.yaml for multi-platform builds.
Config management
- →Ansible playbooks: playbook.yml and roles/*/tasks/main.yml.
- →OpenAPI/Swagger specs: API documentation in YAML.
- →Jekyll/Hugo front matter: Static site post metadata.
- →Cloudformation: AWS infrastructure-as-code (JSON or YAML).
YAML Formatter — examples
Kubernetes Deployment
Standard K8s manifest.
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app:my-appapiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
(Fixed: indentation normalized to 2 spaces, tabs converted, missing space after colon added)Docker Compose
Multi-service stack.
version: 3.8
services:
web:
image: nginx:alpine
ports:
- 80:80
db:
image: postgres:16
environment:
POSTGRES_DB: mydbversion: "3.8"
services:
web:
image: nginx:alpine
ports:
- "80:80"
db:
image: postgres:16
environment:
POSTGRES_DB: mydb
(Warning: version 3.8 looks like float — quote as string)Norway problem
Country code parsed as boolean.
country: NO
⚠ Warning: "NO" parses as boolean false in YAML 1.1 Fix: country: "NO"
Multi-line string
Literal style.
description: | First line Second line
description: | First line Second line
Anchors
Reusable values.
defaults: &defaults timeout: 30 prod: <<: *defaults endpoint: prod.example.com
Preserved as-is (anchors are YAML feature)
Technical details
YAML (YAML Ain't Markup Language) version 1.2 (2009, widely supported). Older 1.1 still used by some parsers (has the Norway problem).
Core syntax:
```yaml
# Scalars (strings, numbers, booleans)
name: Alice
age: 30
active: true
# Lists
tags:
- admin
- user
# Mappings (objects)
user:
name: Alice
email: alice@example.com
# Nested
servers:
- name: web-1
ip: 10.0.0.1
- name: web-2
ip: 10.0.0.2
```
Indentation rules:
- Spaces only — tabs not allowed (classic gotcha).
- Consistent per level — 2 or 4 spaces, pick one and stick to it.
- Relative indent matters — child indented more than parent.
Scalar types:
- String: hello world (no quotes), "with quotes", 'single quotes'.
- Number: 42, 3.14, 1e10.
- Boolean: true/false, or YAML 1.1: yes/no/on/off (Norway problem!).
- Null: null, ~, or empty value.
- Date: 2026-05-05 (parsed as date object).
Multi-line strings:
Literal (preserves newlines):
``yaml``
description: |
This is a multi-line
string with preserved
newlines.
Folded (newlines become spaces):
``yaml``
description: >
This is a long string
that will be rendered
on a single line.
Flow style (JSON-like):
``yaml``
user: {name: Alice, age: 30}
tags: [admin, user]
vs block style (default, more readable):
``yaml``
user:
name: Alice
age: 30
tags:
- admin
- user
Anchors and references:
YAML allows reusing values:
```yaml
defaults: &defaults
timeout: 30
retries: 3
prod:
<<: *defaults
endpoint: prod.example.com
dev:
<<: *defaults
endpoint: dev.example.com
```
Useful for DRY configs.
Common gotchas:
Norway problem:
``yaml`
country_code: NO # Parses as boolean false in YAML 1.1!country_code: "NO"`.
Fix: quote:
Octal confusion:
``yaml`
port: 08 # Parse error in YAML 1.1 (invalid octal)
port: 010 # Parses as 8 (octal) in YAML 1.1port: "08"`.
Fix: explicitly type or quote:
Version numbers:
``yaml`
version: 1.0 # Parses as float 1.0 (not string "1.0")version: "1.0"`.
Fix:
Common YAML tools and their quirks:
- kubectl: K8s client, uses Go YAML 1.2.
- Docker Compose: mostly YAML 1.2 compatible.
- Ansible: YAML 1.1 historically, YAML 1.2 in newer versions.
- GitHub Actions: YAML 1.2.
- Helm: YAML with Go template syntax ({{ }}).
Formatter behavior:
- Normalizes indentation (2 or 4 spaces, configurable).
- Converts tabs to spaces (tabs invalid in YAML).
- Preserves comments (# ...) in original position.
- Keeps flow vs block style as-is.
- Does not change data types (strings stay strings, no auto-conversion).
- Does not resolve anchors (keeps &anchor and *reference as-is).
Common problems and solutions
⚠Tabs in YAML
YAML forbids tabs for indentation — only spaces. Formatter converts tabs to spaces. Fix your editor to insert spaces instead of tabs for .yaml/.yml files.
⚠The Norway problem
YAML 1.1 parses NO, no, yes, on, off as booleans. Country code NO (Norway) becomes boolean false. Fix: quote strings that look like booleans: country: "NO".
⚠Version numbers as floats
version: 1.0 is parsed as float 1.0. If you want string "1.0", quote it: version: "1.0". Common gotcha in Docker Compose, API versions.
⚠Leading zeros
YAML 1.1 treats 08 as invalid octal, 010 as octal 8. Quote ports or IDs: port: "08".
⚠Whitespace at end of lines
Trailing whitespace can confuse some parsers. Formatter removes trailing whitespace. Use editor setting to show trailing whitespace.
⚠Inconsistent indentation
Some lines 2 spaces, some 4, some tabs. Breaks YAML parsing. Formatter normalizes to consistent 2 or 4 spaces throughout.
⚠Multi-line string surprises
| preserves newlines; > folds to spaces. Adding +/- controls trailing newlines. Wrong style may produce unexpected output in consumers.
⚠Helm template syntax
Helm uses {{ }} for templates inside YAML. Standard YAML parsers may choke on unquoted templates. Helm processes them before YAML parsing.
YAML Formatter — comparisons and alternatives
YAML vs JSON: YAML is human-friendly (indentation-based, comments allowed). JSON is machine-friendly (strict syntax, no comments). Same data structures. Use YAML for configs, JSON for APIs.
YAML formatter vs linter: Formatter fixes cosmetic (indentation, spacing). Linter fixes semantic (unknown fields, wrong types). Kubernetes has kubeval, Helm has helm lint. Use both: format first, lint second.
This tool vs prettier YAML plugin: Prettier supports YAML via plugin. Editor integration auto-formats. This tool for ad-hoc quick formatting.
YAML 1.1 vs 1.2: 1.2 fixes Norway problem (requires explicit true/false, not yes/no). Most modern parsers use 1.2 semantics. Check your consumer (some still parse as 1.1).
Block vs flow style: Block (indentation) is human-readable. Flow ({}, []) is JSON-like. Both valid YAML. Block is default and preferred for configs.
YAML vs TOML: Both config formats. YAML is more popular and supports more complex structures. TOML (used by Cargo, poetry) is simpler, more explicit, no significant whitespace — easier to write correctly.
Frequently asked questions about the YAML Formatter
▶What is YAML?
YAML (YAML Ain't Markup Language) is a human-readable data format used for configuration files. Uses indentation for structure, supports scalars, lists, mappings, multi-line strings, anchors. Standardized as YAML 1.2 in 2009. Used everywhere in modern DevOps.
▶Why format YAML?
YAML is whitespace-sensitive — wrong indentation breaks parsing. Formatting normalizes indentation, catches errors, and makes files readable. Essential before committing to a shared repo where teammates need to understand your config.
▶Are tabs allowed in YAML?
No. YAML explicitly forbids tab characters for indentation. Only spaces. This is a major source of errors when editors insert tabs. Configure your editor to use spaces for .yaml files. This formatter converts tabs to spaces automatically.
▶What is the Norway problem?
YAML 1.1 parses NO, no, yes, on, off as booleans. So country code NO (Norway) becomes boolean false, not string NO. Fix: quote strings that look like booleans: country: "NO". YAML 1.2 fixed this (requires explicit true/false).
▶Is my YAML safe here?
Yes. Formatting happens in browser. Kubernetes secrets, AWS keys in configs, and other sensitive data stay on your device.
▶How do I handle tabs in YAML?
Replace with spaces. Configure your editor (VS Code: insertSpaces: true for *.yaml). This tool converts tabs automatically during formatting.
▶Does it support YAML anchors?
Yes. &anchor and *reference syntax preserved. Anchors let you reuse values across a YAML file (DRY principle). Commonly used in Kubernetes manifests and Docker Compose.
▶What about Helm template syntax?
Helm uses {{ }} within YAML. Plain YAML parsers see these as strings and may error on complex templates. Helm processes templates before YAML parsing. This formatter may struggle with complex Helm templates — pass templated YAML through helm template first.
▶How does it handle multi-line strings?
Supports | (literal, preserves newlines) and > (folded, newlines become spaces). Modifiers + (keep trailing newline), - (strip trailing newline) preserved.
▶Can it convert between YAML and JSON?
Not this tool. Use our YAML to JSON and JSON to YAML converters for format conversion.
Additional resources
- YAML 1.2 Specification — Official YAML specification.
- yamllint — Command-line YAML linter.
- Kubernetes YAML Reference — K8s manifest conventions.
- Docker Compose Specification — Compose YAML format.
- The Norway Problem — Why YAML 1.1 is dangerous for certain string values.
Related tools
All Formatters & BeautifiersDocker Compose Generator
Generate docker-compose.yml for multi-container apps — databases, caches, services
Dockerfile Generator
Generate production Dockerfiles for any stack — multi-stage, optimized, secure
Git Commit Message Generator
Create conventional commit messages — feat, fix, docs, with scope and breaking changes
.gitignore Generator
Create .gitignore files for 100+ languages, OS, IDEs — combinable templates
HTML Formatter
Format, indent, and beautify HTML, XHTML, and HTML5 markup
JSON Formatter
Format, validate, and beautify JSON instantly in your browser
Learn more
Explore more tools
200+ free tools that run in your browser.
Browse all tools →