Made some notes on auto-formatting YAML files using yamlfmt (the YAML equivalent of Black and Prettier)

https://til.simonwillison.net/yaml/yamlfmt

Auto-formatting YAML files with yamlfmt

I decided to see if there was an equivalent of Black or Prettier for YAML files. I found yamlfmt from Google.

@simon Looks like something worth trying in pre-commit, though I’ve also found prettier’s YAML formatting perfectly acceptable.

@adamchainz @simon I came here to say this too.

pre-commit is 100% worth learning. A nice bonus is that it'll manage installing/updating/upgrading ruff, black, and others so that you don't have to anymore.

Plus, you get auto-formatting for free(ish).

I would put it on my "stop what you are doing and learn it today" list if you were asking 😄

yamlfmt/docs/pre-commit.md at main · google/yamlfmt

An extensible command line tool or library to format yaml files. - google/yamlfmt

GitHub