YAML formatter
Format, validate and lint YAML, or convert it to JSON. Errors and common pitfalls are explained in plain English.
How to format and validate YAML
- Paste your YAML into the left-hand box (the top box on a phone).
- If it’s valid, the formatted version appears straight away, with any warnings listed above it. If not, the message shows the line and what to fix.
- Choose 2 or 4 spaces, or JSON to convert it, then press Copy.
What the linter checks
- Syntax errors, such as tabs used for indentation, misaligned lines, missing colons and unclosed quotes.
- Duplicate keys in the same mapping.
- yes, no, on and off, which YAML 1.1 tools read as true or false.
- Numbers that change, such as
1.10becoming 1.1, and leading zeros that can be read as octal. - Trailing spaces, which add noise to diffs.
Frequently asked questions
How do I format YAML?
Paste your YAML into the box. It’s checked and reformatted as you type, with consistent indentation and spacing. Choose 2 or 4 spaces, then press Copy. Comments and the order of your keys are kept unless you tick Sort keys.
How do I convert YAML to JSON?
Paste your YAML and choose JSON as the output. Anchors and aliases are expanded, and large numbers are kept exactly. If the file contains several documents (separated by ---), the JSON is a list with one item per document.
Why does it warn about yes, no, on and off?
In YAML 1.1, which tools such as PyYAML and Ansible still use, unquoted yes, no, on and off are read as true or false. That’s why a country code like no (Norway) can turn into false. Put the value in quotes if you mean the text.
Why does it warn about version numbers?
An unquoted value like 1.10 is read as the number 1.1, so the trailing zero disappears. Put version numbers in quotes, like "1.10".
Can I use tabs in YAML?
No. YAML only allows spaces for indentation. Werdz shows the line where a tab was used so you can replace it with spaces.
Is my YAML private?
Yes. Everything happens in your browser, and your YAML is never uploaded or saved, so it’s safe for config files that contain internal hostnames or secrets.