YAML formatter
Paste a YAML file with uneven indentation to get a tidy version with the same values. Useful before a code review or comparing two files.
Loading the tool…
Processing and privacy: The result is calculated inside your browser and your data is not sent to any server.
How to use it
- Enter yaml text, indentation and sort keys alphabetically.
- The result appears straight away and updates as you edit.
- Copy the result, or copy a link that keeps the same values to share it.
How it is calculated
YAML is read into a data structure with the YAML 1.2 core schema and written again: one indentation width, dash and space for each list item, key, colon and space, quotes only on ambiguous strings, and | blocks for multi-line text. With sorting, keys at every level are ordered by character code.
Example
Inputs: Indentation = 2 spaces, Sort keys alphabetically = no. Result: Formatted YAML: server: port: 8080 hosts: - a.example.com - b.example.com name: demo features: - login - search .
server:
port: 8080
hosts: [ a.example.com,b.example.com ]
name: "demo" # app name
features:
- login
- search
server:
port: 8080
hosts:
- a.example.com
- b.example.com
name: demo
features:
- login
- search
Limits and caveats
- Comments are removed, because the file is rebuilt from its values.
- The tool supports a clear YAML subset: maps, lists, scalars, quoted strings, | and > block scalars and [ ] and { } flow collections. Anchors &, aliases *, tags ! and multiple documents are rejected with a clear message.
Questions about this tool
Does formatting change any value?
No. Values and types stay the same; only layout such as indentation and quoting changes.
Why did the comments disappear?
Formatting rewrites the file from its structure, and comments are not part of it. Keep a copy if they matter.
How are keys sorted?
By character code, so capital letters come before small ones, at every level.
