YAML Formatter
100% LocalFormat, minify, and sort YAML with configurable indentation.
Privacy note
This tool runs entirely in your browser. Your input is never uploaded, logged, or sent to AllDevToolsHub or anyone else, and it keeps working offline once the page has loaded.
How to Use YAML Formatter
Paste YAML
Paste your YAML content into the input area.
Choose Options
Set indentation (2 or 4 spaces), and optionally enable key sorting or minification.
Format
Click Format to prettify or Minify to strip comments and whitespace.
Copy Result
Copy the formatted YAML to clipboard.
YAML Formatter: the essentials
The YAML Formatter cleans, validates, and reformats YAML with configurable indentation, key sorting, and minification, built for the Kubernetes manifests, Docker Compose files, and GitHub Actions workflows that make up modern DevOps. Everything runs locally; your infrastructure config never touches a server.
Key points
- Reflows yaml formatter into clean, readable output with standard indentation and keyword casing.
- Runs entirely in your browser, so production data never leaves your device.
- Supports multiple dialects and syntax variants for broad compatibility.
Learn More
What is YAML Formatter?
Frequently Asked Questions
Technical Deep Dive
YAML Formatter
Dedicated YAML prettifier with adjustable indentation (2 or 4 spaces), minification to strip comments and whitespace, and top-level key sorting. Perfect for cleaning up Kubernetes manifests and CI/CD configs.
yamllint is the CI linter. This formatter is for a Compose or Actions file you need to read without sending it to an online YAML site.
Paste jobs:
build:. You should get consistent two-space indent. A tab character should error.
runs-on: ubuntu-latest
YAML 1.1 still treats NO as false (Norway problem). Prefer quoted strings for country codes.
01 YAML Convention Matrix
| Context | Indentation | Best Practice | Critical Failure |
|---|---|---|---|
| Kubernetes | 2 Spaces | Use Kebab-case keys | Tabs in indentation |
| Docker Compose | 2-4 Spaces | Anchor reuse (&) | Missing colon-space |
| GitHub Actions | 2 Spaces | Quoted strings | Invalid YAML 1.1 booleans |
| OpenAPI/Swagger | 2 Spaces | Description blocks | Inconsistent depth |
02 Configuration Pipeline
03 When You Actually Reach for It
YAML formatting isn't cosmetic, it's the cheapest signal you have that a pipeline file will load cleanly before you push it to a cluster or a CI runner.
-
Reviewing GitHub Actions workflows A misaligned
steps:under ajobsilently runs nothing. Paste the workflow in, see the tree at a glance, then push. -
Kubernetes manifests pre-
kubectl applyCatch aspec.template.spec.containersindented one level too shallow before the API server returns a crypticfield is immutable. -
docker-compose with anchors Shared service blocks via
&defaults/<<: *defaultsare easy to typo. Formatting flattens the merge so you can confirm the resolved service tree. -
Helm
values.yamlaudits Chart overrides nest 4–5 levels deep. A consistent indent surfaces accidental siblings that would otherwise override the wrong key duringhelm template. -
Ansible playbooks & OpenAPI specs Long task lists and schema definitions become scannable. Spotting a missing
- name:in a list of dictionaries is instant once indentation is normalized.
04 Worked Examples
countries:- name: Norway
code: no name: Sweden
code: se
countries:
name: Norway
code: false # 'no' was coerced to boolean!
name: Sweden
code: seYAML 1.1 treats yes/no/on/off/y/n as booleans. YAML 1.2 narrowed this to true/false only, but most real-world parsers (PyYAML pre-6.0, libyaml) still default to 1.1. Always quote two-letter country codes: code: "no".
literal: |line one
line twofolded: >
line one
line two
stripped: |-
line one
line two
literal: "line one
line two
" # newlines kept, single trailing
folded: "line one line two
" # newlines folded to spaces
stripped: "line one
line two" # no trailing newline
The chomping indicator (|, |-, |+) controls trailing newlines. Get this wrong in a Kubernetes ConfigMap and a downstream shell script that does cat $FILE | grep … will subtly drift between environments.
&base + merge key:defaults: &base
image: alpine:3.19
restart: unless-stopped
services:
web:
<<: *base
ports: ["8080:80"]
worker:
<<: *base
command: ["./worker"]
services:
web:
image: alpine:3.19
restart: unless-stopped
ports: ["8080:80"]
worker:
image: alpine:3.19
restart: unless-stopped
command: ["./worker"]The << merge key is a YAML 1.1 extension that YAML 1.2 dropped from the core schema. Round-tripping through a strict 1.2 parser (or any tool that resolves before re-emitting) loses your DRY structure, diff against the original before committing.
05 Related Tools
YAML rarely travels alone, these companion tools cover the validation, conversion, and platform-specific checks that pair with formatting.
Kubernetes Validator
After formatting, run the manifest through schema validation to catch apiVersion/kind mismatches before they hit the cluster.
GitHub Actions Validator
Formatting fixes shape; this tool checks that uses:, needs:, and matrix references actually resolve.
JSON Formatter
Convert a YAML config to JSON for a tool that won't read YAML (most AWS SDKs), and confirm the structural intent survived.