Description
keep-sorted is a command-line formatter that sorts the lines between two markers in any text file, whatever the language. You wrap the lines you want kept in order with keep-sorted start and keep-sorted end comments, and running the tool sorts that block. Blocks can be nested. You install it with Go, which the README says must be at least version 1.23, and then run it on your files. Passing a dash as the file name reads from standard input and writes to standard output. By default, running it without file names is an error, but the --allow-no-files flag lets it exit quietly, which helps with hooks that receive empty file lists. You can run it automatically by adding the repository to pre-commit. Options control how lines are grouped. Indented lines count as continuations of the line above by default, which you can turn off with group=no, and block=yes handles multi-line code such as Go structs by matching balanced brackets and quotes.…
Highlights
- Sorts lines between keep-sorted start and end markers
- Works with any text file, whatever the language
- Nested sorted blocks
- Reads stdin and writes stdout
- pre-commit hook support
Ratings & Reviews
No ratings yet
Be the first to rate Keep Sorted.
People also visit
Keep Sorted FAQ
What is keep-sorted?
A language-agnostic formatter that sorts the lines between two markers in a file.
How do I mark lines to sort?
Put keep-sorted start and keep-sorted end in comments around the lines you want sorted.
How do I install it?
Install Go first, at least version 1.23 according to the README, then install keep-sorted with Go and run it on your files.
Can I use it with pre-commit?
Yes. Add the repository to your pre-commit setup and it runs automatically.
Is it open source?
Yes. The source is on GitHub.
What are the best Keep Sorted alternatives?
Popular alternatives to Keep Sorted include Prettier, Biome and Gisto. See all Keep Sorted alternatives







