Make YAML readable
YAML can be written in two styles. The block style puts each key and list item on its own line and uses indentation to show the structure. The flow style uses braces and brackets like JSON, and can pack a lot into one line. The beautifier expands the flow style into the block style, so that the file is easy to read and to compare.
# Flow style
config: {name: demo, ports: [80, 443], env: {MODE: prod, DEBUG: false}}
# Block style
config:
name: demo
ports:
- 80
- 443
env:
MODE: prod
DEBUG: false
JSON is YAML too
Almost every JSON document is also valid YAML. If you paste JSON, the beautifier turns it into block style YAML, which is a quick way to convert it. For a conversion with more options, use JSON to YAML.
How this page is set up
This page starts with Expand flow style turned on and long text wrapped at 80 characters. The same engine runs the YAML formatter, which starts with gentler settings, and you can change every option on both pages.
- Comments and blank lines are kept, unless you tick Remove comments.
- Values are not changed. Only the layout is.
- Sort keys puts every mapping in alphabetical order, which helps when you compare two files.
- If the YAML has an error, you see the error with its line and column, and nothing is changed.
Everything is done in your browser. If you need to make the YAML smaller instead, convert it to JSON with the YAML to JSON converter and use the minified option. The YAML syntax guide explains the two styles in more detail.