YAML Formatter and Validator
Validate a YAML file and rewrite it with clean indentation; if it is invalid, see the line and the reason
Your data stays with you. Conversion happens inside the browser; nothing is sent to a server.
Did this tool do the job?
Thanks, your feedback came through.
How it works
In YAML a single wrong space breaks the whole file: docker compose up or a GitHub Actions workflow stops with a short message like "yaml: line 7". Paste the file into the left box. If the text is invalid, the tool tells you the line of the first error and the reason in plain words: a tab used for indentation, a key written twice in the same block, a quote or square bracket left open, or lines on the same level starting with a different number of spaces. If the text is valid, it is rewritten on the right with consistent indentation: in the sample, the image line pushed in by 8 spaces moves back to 4, list items (- "8080:80") are indented two spaces under their parent key, and extra spaces are cleaned up. Comments written with #, the order of keys and multiple documents separated by --- stay as they are. The result line gives the number of documents and lines.
This tool is also known as yaml formatter, yaml validator, yaml beautifier, yaml lint online, validate yaml online, docker compose yaml validator.
What is YAML?
YAML (YAML Ain't Markup Language) is a data format designed for configuration files that people can read and write. Instead of braces and quotes it uses indentation: key: value lines and list items starting with - nest according to how many spaces they are indented. docker-compose, GitHub Actions, Kubernetes, Ansible and Home Assistant settings are written in YAML. It supports comments (#), which JSON does not.
What is Indentation?
In YAML, indentation is the number of spaces at the start of a line, and it is structure, not decoration: lines under a key that start with more spaces belong inside that key. Lines on the same level must start with the same number of spaces. How many spaces you use is up to you (2 is the most common), but a tab character is never accepted as indentation.
What is the difference between YAML and JSON?
Both carry the same kinds of data (keys and values, lists, numbers, text), and every JSON document is also valid YAML. The difference is how they are written: JSON builds structure with braces and square brackets, YAML with indentation. YAML allows comments and unquoted text, which is why it is preferred for hand-edited config files. JSON is stricter and is used for data exchange between programs and in APIs. To switch from one to the other, use the JSON to YAML tool.
The most common YAML errors and what they mean
YAML reads indentation as meaning: how many spaces a line starts with decides which key it belongs to. That is why a tab character inserted by the Tab key is forbidden; it looks like spaces but YAML rejects it. If two lines on the same level start with 2 and 3 spaces, the file either fails or turns into a different structure than you expected.
The second common error is a duplicate key: writing ports: twice in the same block. Some programs silently accept this and use the second one, so your first setting is lost; this tool follows the YAML 1.2 rule, reports an error and shows the line. The third is a missing space after the colon: image:nginx is not a key and value but a single piece of text.
- "tabs cannot be used" → replace the Tab at the start of the line with spaces
- "key appears a second time" → delete or merge one of the two lines
- "quote is not closed" → count the " or ' marks on that line
What does rewriting change and what does it keep?
The tool reads the file and writes the same data back: indentation becomes consistent, list items move one level under their parent key, and extra spaces before comments shrink to one. Keys, values, comments and the order of keys are kept; quoted text such as "false" stays quoted, because removing the quotes would turn it into a boolean.
Alphabetical sorting is optional and sorts each block on its own; a comment above a key moves with that key. In docker-compose or Kubernetes files the order carries no meaning, but there is a familiar reading order (image first, ports later), so keeping the order is the default.
Frequently asked questions
How do I check whether my YAML file is valid?
Paste the content into the left box on this page. If it is valid, the result line says "Valid YAML" and the file appears on the right with clean indentation. If it is invalid, you see the line number and the reason for the first error.
Are my comments removed?
No. Full-line comments starting with # and comments at the end of a line stay where they are. Converting to JSON would remove comments; this tool writes YAML back as YAML, so it keeps them.
Does it work for docker-compose.yml and GitHub Actions files?
Yes. The tool checks the general YAML rules, and docker-compose, GitHub Actions, Kubernetes, Ansible and Home Assistant files are all YAML. It does not check whether a key is valid for that particular program, such as a misspelled docker option.
Is my file sent to a server?
No. Validation and formatting run entirely in your browser; the text you paste, including config files with passwords or keys, never leaves this page.