Skip to main content

YAML Formatter

Reformat YAML with consistent indentation, check it for errors, and convert between YAML and JSON. Runs in your browser, nothing uploaded.

This tool runs entirely in your browser. Nothing you enter is sent to our servers, so there is nothing for us to store or see.

About the YAML Formatter

Paste YAML and get it back with consistent indentation, or convert it to JSON — and back again, since every JSON document is already valid YAML. Handy for a CI pipeline, a Kubernetes manifest, a Docker Compose file or an OpenAPI spec that has been edited by four people with three different editors.

YAML gets its meaning from indentation, so the errors are unusually easy to make and unusually hard to see. Errors are reported with a line number and an explanation: a tab used for indentation (which YAML forbids outright), a key repeated in the same mapping, a quote never closed, a list item that does not line up with its neighbours.

Scalars are resolved with the YAML 1.2 core schema, where only true and false are booleans. Under the older 1.1 rules yes, no, on and off were booleans too — which is why a country list containing NO famously turned Norway into false. When writing YAML back out, any value that a 1.1 parser would misread is quoted, so the result is safe whichever version reads it next.

Anchors, aliases and merge keys are not supported. Rather than quietly dropping them and handing back a file that has lost its shared configuration, the tool says which line uses one and stops.

How to use the YAML Formatter

  1. Paste your YAML

    Into the left box, or drop a .yml or .yaml file onto it. JSON works here too — it is a subset of YAML.

  2. Pick the output

    YAML to reformat it in place, or JSON to convert. A stream containing several documents becomes a JSON array.

  3. Set the indentation

    Two spaces is the convention almost everywhere, including Kubernetes and GitHub Actions. Four is available where a house style calls for it.

  4. Fix anything reported

    Errors name the line and explain what is wrong — a tab, a duplicate key, an unclosed quote, or indentation that does not line up.

Frequently asked questions

Why can I not use tabs to indent YAML?

The YAML specification forbids them outright for indentation, because a tab has no defined width and the whole format depends on comparing column positions. Editors that show a tab as two spaces make a file look correct while every parser rejects it, which is why the error is reported explicitly rather than as a generic syntax failure.

What is the Norway problem?

Under YAML 1.1, the unquoted values yes, no, on and off were booleans. So a list of country codes containing NO parsed as false rather than "NO", silently corrupting the data. YAML 1.2 fixed it by making only true and false boolean, which is the rule this tool follows — and it quotes anything a 1.1 parser would still get wrong.

Why does it refuse files with anchors and aliases?

Because reformatting them correctly means resolving what they point at, and writing the result back out would either expand them — changing the document — or risk dropping them. A file that loses its anchors still parses and looks fine, which makes it the worst kind of failure. Refusing is the honest answer.

Can I convert JSON to YAML with this?

Yes. Paste JSON, leave the output set to YAML, and you get the YAML equivalent. It works because JSON is a strict subset of YAML 1.2, so the same parser reads both — there is no separate conversion path that could disagree with the formatter.

Is my configuration file uploaded anywhere?

No. Parsing and formatting happen entirely in your browser and nothing is transmitted or stored. That matters more here than for most tools, because a CI or deployment file is exactly the kind of thing that contains hostnames, bucket names and occasionally a secret somebody forgot to move.