Sort YAML

Use the Sort YAML tool to alphabetically organize keys in your YAML files. Sort deeply, preserve top-level order, and preview changes instantly.

Paste your input above or import a file below.
No file chosen
Supported file types: .yaml, .yml, .txt, .json, .ini, .md, .xml
Total characters: 0
Options
Sort deeply
Preserve top-level order
Maximize output

How to Use:

  • Paste your YAML into the Input Text box or import a file using Choose File below the input.
  • Toggle Sort deeply to recursively sort all nested YAML keys alphabetically.
  • Toggle Preserve top-level order if you only want to sort child keys but leave the top-level unchanged.
  • Toggle Maximize output to expand the output area if you’re working with larger YAML files.
  • Click Sort to process your YAML with the selected options.
  • Use Copy Output to copy the result to your clipboard.
  • Click Export to File to save the sorted YAML as a .yaml file.
  • Hit Clear All to reset the input, output, and toggles to their default states.

What Sort YAML can do:

The Sort YAML tool gives you a quick way to clean up messy YAML structures by putting keys in alphabetical order. It can do shallow or deep sorting depending on how structured your YAML is. If you’re working with config files, Kubernetes manifests, or nested data, sorting can help make things easier to read and maintain. The deep sort option reorganizes everything from the top down, while the preserve top-level setting lets you keep your top sections intact but clean up what’s inside. You get instant results as you type or import plus copy and export tools to speed up your workflow.

Example:

Before:
settings:
version: 2.0
theme: dark
autosave: true

After:
settings:
autosave: true
theme: dark
version: 2.0

Common Use Cases:

Ideal for developers and sysadmins working with structured YAML configs. You can clean up cluttered files, enforce ordering for diffs, or just make large documents easier to navigate. Great for Ansible, Kubernetes, or CI/CD YAML management.

Useful Tools & Suggestions:

Before sorting your YAML, try Validate YAML to make sure there aren’t any syntax issues that’ll trip things up. And if you want a cleaner result afterward, Prettify YAML makes the sorted structure easier to scan.