YAML Formatter
Paste YAML. Format it, check it as you type, get the JSON. Nothing leaves your browser.
- 0
- Lines
- 0
- Keys
- 0
- Errors
On this page
About YAML Formatter
Updated
What is a YAML Formatter?
A YAML Formatter takes your YAML and turns it into a clean, consistently indented, easy-to-read file. YAML (YAML Ain't Markup Language) is a human-readable data serialization language that is widely used for configuration files, infrastructure as code, and data exchange.
How to use this tool
Type or paste your YAML into the editor and press Format. Comments stay where they are. The tool checks your YAML as you type: when something is wrong, it rings the exact spot, gives the line and column, and says what to fix. Lines that Format changed stay marked until you edit them, and Show before shows your text as it was.
Summarize YAML
The Result pane counts the documents, keys, lists and values in your YAML, and shows the nesting depth. Open Notes to see each top-level key and what it holds, next to its line.
Convert YAML to JSON
Open the JSON tab in the Result header to see your YAML as JSON. Copy and Download then take the JSON. A file with several documents becomes a JSON array. To go the other way, use JSON to YAML.
Customization
Open Options to set the indent, whether short lists and maps in brackets stay on one line or always go on separate lines, double or single quotes, the line width, and sorting keys A to Z. The tool remembers your choices.
YAML vs JSON
YAML and JSON are both data serialization formats, but they serve slightly different purposes. JSON is more compact and widely used for APIs and data exchange, while YAML is easier to read and common in configuration files. Since YAML 1.2, valid JSON is also valid YAML, but YAML adds comments, anchors, aliases, and multi-line strings.
Common YAML syntax errors
Incorrect indentation
YAML uses indentation to define structure. Mixing tabs and spaces, or using different indents at the same level, is the most common source of YAML errors. Always use spaces, never tabs, and keep the same number of spaces per level.
server:
host: example.com
port: 8080server:
host: example.com
port: 8080Missing colons or spaces
A key and its value need a colon followed by a space: key: value. Without the space, key:value is read as one plain text value, not a key.
Unquoted special characters
Values that start with special characters such as {, [, *, & or @, or that contain : or #, must be quoted. Without quotes, the parser reads these characters as structure or as a comment.
message: Error: disk full
channel: @opsmessage: "Error: disk full"
channel: "@ops"YAML best practices
- Use 2 spaces for indentation, the most common convention in the YAML ecosystem.
- Never use tabs for indentation. The YAML specification forbids them.
- Quote values that could be read as another type, such as "true", "3.14" or "null", when you mean them as text.
- Use comments (
#) to document complex configurations. - Use anchors and aliases to avoid repetition in large files.
- Validate your YAML before you deploy, to catch errors early.
YAML
YAML (YAML Ain't Markup Language) is a human-readable data serialization language. It was first proposed by Clark Evans in 2001 and has become one of the most popular formats for configuration files. YAML is designed to be easy to read and write, which makes it a natural choice for configuration management, infrastructure as code, and data exchange between systems.
- The conventional extensions for YAML files are
.yamland.yml. Both are widely used, and.yamlis the officially recommended one. - The MIME type for YAML is
application/yaml, as registered in RFC 9512.
Why use YAML?
YAML is the standard for configuration in the DevOps world. Its clean, indentation-based syntax makes complex configuration readable at a glance, which matters when you manage infrastructure and deployment pipelines.
- YAML is easier to read than JSON or XML, with very little syntax.
- YAML supports comments, so you can document configuration choices inline.
- YAML supports anchors, aliases, and merge keys to reduce repetition in large configuration files.
- Valid JSON is also valid YAML, so you can use JSON syntax inside YAML files when needed.
Common YAML use cases
- Docker Compose. Define multi-container applications with services, networks, and volumes in
docker-compose.yml. - Kubernetes. Declare deployments, services, config maps, and other resources as YAML manifests.
- GitHub Actions. Define CI/CD workflows in
.github/workflows/. - Ansible. Write playbooks, roles, and inventory files to automate server setup and configuration.
- CI/CD pipelines. Configure build and deployment pipelines in GitLab CI, CircleCI, and other platforms.
- Application config. Many frameworks and tools, such as Spring Boot, MkDocs, Prettier and ESLint, accept YAML configuration files.
YAML 1.2 specification
The current version of YAML is YAML 1.2 (revision 1.2.2), released in October 2021. YAML 1.2 aligned YAML with JSON, removed several surprising implicit types (such as reading unquoted yes and no as booleans), and made the data model clearer. YAML 1.2 is the recommended version for new projects.
Other YAML resources
- YAML Official WebsiteThe official YAML website with links to the specification and resources.
- YAML 1.2.2 SpecificationThe latest revision of the YAML specification, with the complete syntax and data model.
- Learn YAML in Y MinutesA quick, practical introduction to YAML syntax with annotated examples.
- Docker Compose File ReferenceThe official Docker Compose file reference, one of the most common uses of YAML.
- Kubernetes ObjectsKubernetes documentation on defining workloads and resources with YAML manifests.
- GitHub Actions Workflow SyntaxThe official reference for GitHub Actions workflow files, which use YAML.
- Ansible YAML SyntaxAnsible documentation on the YAML syntax for playbooks, roles, and configuration.
YAML FAQ
What YAML features does this formatter support?
It supports the YAML 1.2 specification, including nested mappings, sequences, multi-line strings, anchors, aliases, and files with several documents separated by ---. It uses the yaml library for parsing and formatting.
Can I use this tool for Kubernetes YAML files?
Yes. It works with all YAML files, including Kubernetes manifests, Docker Compose files, GitHub Actions workflows, Ansible playbooks, Helm values, and any other YAML configuration.
Does the formatter keep comments?
Yes. Comments stay where they are, next to the keys and values they describe. Only the layout changes: indents, quotes and line breaks.
What does YAML stand for?
YAML first stood for "Yet Another Markup Language". It was later renamed to the recursive acronym "YAML Ain't Markup Language", to show that it is a data serialization language, not a markup language for documents.
Is YAML a superset of JSON?
Yes, since YAML 1.2, valid JSON is also valid YAML. YAML adds features that JSON does not have, such as comments, anchors, aliases, and multi-line strings.
Are tabs allowed in YAML?
No. The YAML specification does not allow tabs for indentation, because editors and tools show tabs at different widths. Use spaces.
Who invented YAML?
YAML was first proposed by Clark Evans in 2001, together with Ingy döt Net and Oren Ben-Kiki. The latest revision, YAML 1.2.2, was published in October 2021. The official website is yaml.org.
When should I choose YAML over JSON?
YAML is often the better choice for configuration files that people read and edit often. JSON is better for data exchange between systems and APIs. If you need comments, multi-line strings or easy-to-read configuration, choose YAML. If you need strict parsing between machines, choose JSON.