YAML

YAML Formatter

Re-prints a YAML document with consistent indentation and quoting, and is honest that comments do not survive the trip.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste the YAML you want re-indented.
  2. Choose two or four spaces, and whether the output should start with a --- marker.
  3. Select Format. Keep the original if its comments matter, because the formatted copy will not have them.
  4. Copy the result, or download it as a file.

What yaml formatter does

Formatting YAML means reading the document into values and writing those values back out. That fixes mixed indentation, inconsistent quoting and the ragged spacing that appears when three people have edited the same file, and it is the quickest way to see what a confusing document actually says once the layout stops arguing with the structure.

It also loses your comments, and there is no way around that. A YAML comment is attached to nothing — it sits between tokens and belongs to no key — so once the document has been read into values there is nowhere to put a comment back. Keep the original if the comments matter, and use this to understand a file or to normalise one that was generated rather than written.

Frequently asked questions

Because formatting reads the document into values and writes those values out again, and a YAML comment belongs to no value — it sits between tokens. Once the document is values there is nowhere to put a comment back. Keep the original file if the comments matter.

The values are unchanged, but their written form may not be. A value YAML read as the number 1.1 is written back as 1.1, so a version string that was written unquoted as 1.10 will come back as 1.1. Quote such values in the source before formatting.

It stays a block scalar. Multi-line text is written back with the | marker and its original line breaks rather than being folded into one quoted line with escapes in it, because that is both what you wrote and what is readable.