Any auto formatter for toml?

  1. Do people use auto formatter for Cargo.toml?
  2. Any good formatter that do not make toml less readable?
  3. Any toml formatter that preserve comments?

Searched on, one way is to call toml::ser::to_string,
which generates less readable toml like this

workspace = true

workspace = true

While I prefer to

serde.workspace = true
serde_json.workspace = true
1 Like

I use GitHub - tamasfe/taplo: A TOML toolkit written in Rust with the following configuration

align_comments = false
reorder_keys = true

include = ["**/Cargo.toml"]
keys = ["package"]

reorder_keys = false

in addition to the standalone cli tool, there's a vscode extension too: Even Better TOML


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.