YAML Formatter
Tidy YAML or convert it to JSON.
Format YAML online with consistent 2 or 4-space indentation, optional key sorting, and one-click conversion to JSON. Validates as you type and reports syntax errors by line and column. Perfect for Kubernetes, CI, Docker Compose and Ansible files. Runs fully in your browser.
How to use YAML Formatter
Paste your YAML
Paste your YAML or upload a .yaml or .yml file into this free online YAML formatter to tidy and validate it instantly in your browser, with nothing uploaded.
Set indentation
Choose 2 or 4-space indentation so the formatter normalises spacing and expands flow style, making Kubernetes, Docker Compose and CI manifests readable.
Sort keys optionally
Turn on sort keys to reorder mapping keys alphabetically from A to Z, keeping large config files consistent and easy to scan.
Convert to JSON
Switch on Convert to JSON instead and the YAML formatter parses your file and outputs valid, formatted JSON in one click as a fast YAML to JSON converter.
Catch syntax errors
Invalid indentation, tabs or a missing space after a colon are pinpointed by line and column so you can fix the YAML instantly.
Copy or download
Copy the formatted YAML or JSON to your clipboard, or download it as a ready-to-use .yaml or .json file straight from your browser.
Frequently asked questions
Why is my YAML invalid?
The usual culprits are inconsistent indentation, using tabs instead of spaces (YAML forbids tabs for indentation), or a missing space after a colon. The error banner shows the line and column so you can fix it quickly.
Does it support anchors and aliases?
Yes — the parser resolves anchors (&) and aliases (*). When re-emitting, repeated structures are expanded inline rather than re-using references, which keeps the output unambiguous.
Can I convert JSON to YAML too?
This tool converts YAML to JSON. Since all valid JSON is also valid YAML, you can usually paste JSON here and format it as YAML by leaving “Convert to JSON” off.
Is my configuration uploaded?
No. Everything is parsed and formatted locally in your browser, so secrets in config files never leave your machine.
How do I format and beautify YAML online for free?
Paste your YAML into this free online YAML formatter and it instantly re-indents and beautifies it with consistent 2 or 4-space spacing — no sign-up or install. It's ideal for tidying Kubernetes manifests, Docker Compose, CI pipelines and Ansible playbooks.
How do I convert YAML to JSON?
Turn on “Convert to JSON instead” and the tool parses your YAML and outputs valid, formatted JSON in one click — a fast YAML to JSON converter that runs entirely in your browser.
Why does YAML break with tabs?
YAML forbids tab characters for indentation — only spaces are allowed, which is one of the most common reasons YAML is invalid. If your file uses tabs the parser stops with an error, and this tool pinpoints the exact line and column so you can replace those tabs with spaces and try again.
Are my comments kept when I reformat?
No. To reformat, the tool parses your YAML into data and re-emits it, and that process drops all # comments. If you need to keep comments, reformat a copy — or only use the tool to validate and tidy indentation on files without important comments.
Can it fix my YAML indentation automatically?
Yes. Paste YAML with uneven spacing and the formatter re-emits it with consistent 2 or 4-space indentation, which fixes the single most common cause of YAML errors. If tabs are present it flags them, since YAML only allows spaces for indentation.
Is this useful for Kubernetes or Docker Compose files?
Very. Kubernetes manifests, Docker Compose, GitHub Actions, GitLab CI and Ansible playbooks are all YAML, and this tool tidies their indentation, validates the syntax and can convert them to JSON — all in your browser, so config secrets never leave your machine.
Related tools — Formatters & validators
- JSON Formatter — Beautify or minify JSON with live error checking.
- JSON Validator — Validate JSON and pinpoint syntax errors.
- XML Formatter — Pretty-print or minify XML, well-formedness checked.
- XML Validator — Check XML is well-formed and locate errors.
- SQL Formatter — Standardise SQL with dialect-aware formatting.
- SQL Beautifier — Turn cramped one-line SQL into readable queries.