Formatted YAML will appear here...
What is YAML Formatter?
YAML (YAML Ain't Markup Language) is a human-friendly data serialization format used extensively in configuration files for Docker Compose, Kubernetes, GitHub Actions, Ansible, GitLab CI, and many other DevOps tools. Improperly formatted YAML — inconsistent indentation, missing spaces after colons, or accidental tabs — can cause hard-to-trace parse errors that waste hours of debugging time. This formatter normalizes your YAML to a consistent style by fixing indentation, adding missing spaces after colons, correcting list item spacing, and collapsing excessive blank lines — all while preserving the original data structure and key order.
How to Use
- Paste your YAML into the editor — any valid or slightly malformed YAML will work.
- Select the indentation size (2 or 4 spaces) to match your project's style guide.
- Click "Format" to normalize and beautify the YAML — the formatter fixes indentation, spacing, and list formatting.
- Check the warnings panel for tab characters or other issues that the formatter detected but could not automatically fix.
- Copy the formatted output using the "Copy" button for use in your configuration files.
Why Use This Tool?
Tips & Best Practices
- YAML is whitespace-sensitive — always use spaces for indentation, never tabs, as required by the specification
- Keep indentation consistent: pick 2 or 4 spaces and stick to it throughout the entire file
- String values that look like numbers (e.g., version: "1.0") should be quoted to prevent type coercion by YAML parsers
- Colons inside values must be quoted: url: "https://example.com" — without quotes, the parser may interpret the colon as a key separator
Frequently Asked Questions
Why does YAML not allow tabs?
The YAML specification explicitly prohibits tab characters for indentation because different editors and terminals display tabs differently. A file indented with tabs might look correct in one editor but parse incorrectly in another. The spec requires spaces only, making the indentation unambiguous and consistent across all tools.
Why am I getting "mapping values are not allowed here"?
This error usually means: (1) a colon inside an unquoted string value — quote the value; (2) incorrect indentation mixing mappings and sequences; or (3) a duplicate key on the same level. The formatter normalizes spacing but cannot fix structural logic errors — use the YAML Validator for deeper diagnosis.
Does formatting change the meaning of my YAML?
Normalization of whitespace (indentation, spaces after colons) does not change the parsed data structure. However, reordering keys or changing quoting style could technically affect tools that depend on key order. This formatter only normalizes whitespace and does not reorder keys or change quoting.
When should I NOT use YAML?
Avoid YAML when you need strict type safety — YAML's automatic type coercion can surprise you (e.g., "yes" becomes true, "1.0" becomes a float). Also avoid YAML for very large configuration files where the whitespace sensitivity becomes a maintenance burden. JSON or TOML with their simpler parsing rules may be more reliable for complex or team-edited configurations.
Is my YAML configuration safe to paste here?
Yes. All formatting happens entirely in your browser using JavaScript. Your YAML content is never sent to any server, stored, or transmitted. You can safely format configuration files containing internal hostnames, API endpoints, or other sensitive information.
Real-world Examples
Formatting a Docker Compose File
A Docker Compose file with inconsistent indentation and missing spaces after colons. The formatter normalizes the structure for reliable parsing.
services:
web:
image:nginx:latest
ports:
-"80:80"services:
web:
image: nginx:latest
ports:
- "80:80"Fixing Tab Characters in a Kubernetes Config
A developer accidentally used tabs instead of spaces in a Kubernetes deployment YAML. The formatter detects the tabs and warns before they cause a parse error on the cluster.
spec: replicas: 3 selector: matchLabels: app: my-app
Warning: Line 2: tab character found — YAML requires spaces for indentation