Code Tools

YAML Key Sorter

All tools

Put every key in a YAML settings map into alphabetical order, at every level of nesting.

How it works

Four simple steps

1

Paste a settings map

Use key: value YAML without lists, such as an i18n file.

2

Keys are sorted

Every map, nested ones included, is put in alphabetical order.

3

Review the output

Strings are quoted and comments are gone, so scan before saving.

4

Copy or download

Take the sorted YAML back to your project.

YAML Key Sorter

About YAML Key Sorter

A translation file or a feature-flag config has grown by appending keys at the bottom, and finding anything now means searching. Sorting the keys alphabetically makes the file predictable and keeps future diffs small.

The sorter reads your YAML, reorders the keys of every map alphabetically, nested maps included, and writes the result back as YAML with two-space indentation. Numbers, true, false and null keep their types, and string values are written in double quotes so nothing is reinterpreted on the way back. The output refreshes as you type and can be copied or downloaded.

Know the limits before using it on a real file. The tool relies on a small built-in reader designed for key: value maps. List items (lines starting with a dash) are not read, so a key holding a list comes out empty, and comments are discarded, except that an inline comment after a value is kept as part of the string. Multi-line strings and anchors are not supported either. That makes it a good fit for i18n files and flat config maps, and a poor one for Kubernetes or CI files. Sorting uses plain character order, so uppercase keys come before lowercase ones. Check the output with the YAML syntax checker, and if you sorted to make a comparison cleaner, continue in YAML Diff. For a simple one-item-per-line list, Sort Lines is often enough.

Everything runs on a parser bundled with the page, so no library is fetched and the file stays local.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

The built-in reader only understands key: value lines, and list entries are skipped. Remove lists before sorting and add them back afterwards, or sort that file by hand.

The writer quotes every string value so that text like yes, 1.0 or 2024-01-01 cannot be read back as a boolean, number or date. The quotes are valid YAML and do not change the value.

Yes. Keys are compared by character code, so Zebra sorts before apple. Lowercase your keys first if you need a case-insensitive order.

View more FAQs

Related tools

View all

HTML Formatter

Beautify and indent HTML markup.

Open

CSS Formatter

Format and pretty-print CSS.

Open

JS Formatter

Beautify JavaScript code.

Open

JSON Formatter

Beautify and validate JSON.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools