Output appears here.
The YAML Formatter re-indents YAML consistently, validates it and reports syntax errors with the exact line and column. Comments are kept. It suits Kubernetes manifests, Docker Compose files, GitHub Actions workflows and Helm values — anywhere a stray space breaks a deploy. Formatting runs in your browser, and nothing is uploaded.
How to format YAML
- Paste YAML into the input pane, drop a
.yamlor.ymlfile, or press ⌘/Ctrl O. - Choose Indent (2 or 4 spaces) and, if needed, a Quote style or Line width. Switch to Validate mode when you only want to lint the file.
- Copy the result with ⌥/Alt C, download it with ⌘/Ctrl S, or use a Next action: Sort keys, Validate, or convert the YAML to JSON.
Examples
Kubernetes deployment with mixed indentation
The metadata block uses four spaces while the rest of the file uses two, and the container list sits flush with its parent key. The formatter normalizes both.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels: {app: web, tier: frontend}
spec:
replicas: 3
template:
spec:
containers:
- name: web
image: "nginx:1.27"Result:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels: { app: web, tier: frontend }
spec:
replicas: 3
template:
spec:
containers:
- name: web
image: "nginx:1.27"Workflow file with comments, double quotes
A GitHub Actions fragment formatted with Quote style set to Double. Comments stay where they were, and quoted strings stay quoted — '20' does not become the number 20.
# CI settings
on:
push:
branches: [ main ]
env:
NODE_VERSION: '20' # keep in sync with .nvmrc
CACHE: 'true'Result:
# CI settings
on:
push:
branches: [ main ]
env:
NODE_VERSION: "20" # keep in sync with .nvmrc
CACHE: "true"Bad indentation
The ports key is indented by three spaces instead of four, so it no longer lines up with image.
services:
web:
image: nginx
ports:
- "80:80"Result:
All mapping items must start at the same column (line 4, column 1)
This line is indented differently from its siblings. Items at the same level must line up exactly.Options explained
- Indent — the number of spaces per nesting level, 2 or 4; YAML does not allow tabs for indentation, so there is no tab option.
- Quote style — Preserve keeps each string's original quoting, while Single or Double rewrites every already-quoted string to that style; plain unquoted strings are left alone.
- Line width — long plain strings are folded onto continuation lines at 80 or 120 characters, or never with Unlimited.
- Sort keys — orders the keys of every mapping alphabetically, which helps when comparing two versions of a large config.
Troubleshooting YAML errors
YAML errors are almost always about whitespace or a missing colon. The error panel quotes the parser message with its line and column, then adds a plain-language hint. Press F8 to jump to the line.
All mapping items must start at the same column
Keys at the same level must line up exactly. Count the spaces on the flagged line and match its siblings. The YAML indentation guide explains how the parser decides which block a line belongs to.
Tabs are not allowed as indentation
YAML forbids tab characters in indentation, and they are invisible in most editors. Replace the leading tabs on the flagged line with spaces.
Map keys must be unique
The same key appears twice in one mapping — often after merging two snippets. YAML parsers disagree on which value wins, so the formatter treats duplicates as an error. Delete or rename one of them.
A flow collection is not closed
An inline {…} or […] is missing its closing brace or bracket. The parser keeps reading the following lines as part of the unfinished collection, so its message, such as "Flow map in block collection must be sufficiently indented and end with a }", points at the next line. The hint says it directly: "A [ or { is not closed, or items inside it are missing commas." Close the bracket on the line above.
A value turned into a string instead of a key
url:http://example.com with no space after the colon is a valid plain string, not a key-value pair, so it formats without an error but has the wrong meaning. Always write key: value with a space.
FAQ
Does the formatter keep my comments?
Yes. Comments on their own line and at the end of a line are preserved, and they stay attached to the key that follows or precedes them. This is the main difference from converting YAML to JSON and back, which loses every comment because JSON has none.
Is it safe to paste Kubernetes secrets or CI config?
Yes. The formatter runs in your browser inside an isolated frame that blocks network requests, so values such as base64-encoded secrets and tokens never leave your device and nothing is stored on a server. Your settings are remembered locally; the input is only kept if you turn on "Remember my last input".
Will formatting change the meaning of my YAML?
It should not. The document is parsed and printed back with the same values, types, anchors and comments; only indentation, spacing and, if you ask, quoting and key order change. Quoted strings stay quoted, so '20' and 'true' remain strings.
What happens to comments when I sort keys?
A comment belongs to the key it sits above, so it moves with that key. A comment at the very top of the file, directly above the first key, will travel with that key to its new sorted position. Move header comments back by hand, or format without sorting.
Can it handle files with several documents?
Yes. Documents separated by --- are formatted one by one and joined again with the separator, and the status line shows how many documents were found. This is common in Kubernetes manifests that bundle a Service and a Deployment in one file.
Does validation check my Kubernetes or Compose schema?
No. The validator checks YAML syntax — indentation, colons, quotes, brackets and duplicate keys. It does not know which fields a Deployment or a Compose service requires. A file can be valid YAML and still be rejected by kubectl for a misspelled field name.
Related tools
To feed YAML into code that expects JSON, convert YAML to JSON; to go the other way, use JSON to YAML. The guide JSON vs YAML covers when each format fits. More formatters and converters are listed under data tools.
Related tools
Guides
- YAML Indentation: Why It Breaks and How It Really Works — Why does my YAML fail to parse?