Sort YAML mapping keys recursively without changing sequence order.
The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.
Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.
Mappings are traversed and keys sorted lexically in ascending or descending order, while sequences retain their order and nested mappings are sorted. The resulting values are serialized back to YAML.
server: port: 3000 host: localhost database: port: 5432 host: db.example.com name: myapp app: name: MyApp version: 1.0.0
app: name: MyApp version: 1.0.0 database: host: db.example.com name: myapp port: 5432 server: host: localhost port: 3000
Kubernetes values, CI snapshots, and generated artifacts sort YAML keys.