# YAML formatter and validator

Paste YAML to re-indent it to 2 or 4 spaces. Comments, key order, quotes, anchors and block text stay as written, and the result is checked to hold the same data. Nothing is uploaded.

Page: https://toolkitnow.org/tools/yaml-formatter/

Paste YAML to fix its indentation. Comments and everything else stay as written. The gray text is an example.

## Good to know

### What changes

Indentation, spaces at the ends of lines, and Windows line endings (they become plain line breaks). A block's indentation number, as in `|2`, is updated to match. Comments, key order, quotes and block text (`|` and `>`) stay as written.

### Checked

The formatted YAML is read back and compared with yours, and shown only if it holds the same data. Files with several documents (`---`) are checked one document at a time. Files this page cannot read back yet (anchors, tags, values spread over several lines) are not formatted; the message says which line.

### Lists

A list item keeps its ` -  `, and the keys under it line up after it. Lists written at the same indent as their key stay that way.

### Tabs

YAML does not allow tabs for indentation. The first one is named with its line.

### yes and no

Read as text, as in YAML 1.2 (also `on` and `off`). Older YAML 1.1 tools such as PyYAML read them as true and false. One-line output puts them in quotes, so every reader agrees.

### One line

Writes the data on a single line in YAML's flow style, like JSON with fewer quotes. Comments are not kept there. To convert to JSON itself, use [YAML to JSON](https://toolkitnow.org/tools/yaml-to-json/).

### Open from a link

`?input=a:%0A%20%20%20%20b:%201` opens the page with that YAML; add `&indent=4` or `min`.

Runs in the browser; nothing is uploaded. Part of toolkitnow.org.
