cargo-fmt-toml

Crates.iocargo-fmt-toml
lib.rscargo-fmt-toml
version0.0.8
created_at2026-01-03 12:18:28.368412+00
updated_at2026-01-16 01:22:32.111949+00
descriptionCargo subcommand to format and normalize Cargo.toml files according to workspace standards
homepagehttps://github.com/dataroadinc/cargo-fmt-toml
repositoryhttps://github.com/dataroadinc/cargo-fmt-toml
max_upload_size
id2019989
size166,625
Jacobus Geluk (jgeluk)

documentation

https://docs.rs/cargo-fmt-toml

README

cargo-fmt-toml

Crates.io Documentation CI License: MIT Downloads

Cargo subcommand to format and normalize Cargo.toml files according to workspace standards.

Installation

Using cargo-binstall (Recommended)

The fastest way to install pre-built binaries:

cargo install cargo-binstall
cargo binstall cargo-fmt-toml

Using cargo install

Build from source (slower, requires Rust toolchain):

cargo install cargo-fmt-toml

Features

  1. Workspace Dependencies: Ensures all dependency versions are managed at workspace level
  2. Internal Dependencies: All workspace crates use { workspace = true } for consistency
  3. Sorted Dependencies: All dependency sections are sorted alphabetically by name
  4. Package Section Format: Enforces a consistent [package] section format

Usage

# Format all Cargo.toml files in the workspace
cargo fmt-toml

# Preview changes without modifying files
cargo fmt-toml --dry-run

# Check if files need formatting (returns non-zero if changes
# needed)
cargo fmt-toml --check

Package Section Format

The tool enforces this exact format for the [package] section:

[package]
name = "crate-name"
description = "Brief description"
version = { workspace = true }
edition = { workspace = true }
license-file = { workspace = true }
authors = { workspace = true }
rust-version = { workspace = true }
readme = { workspace = true }

Dependency Sorting

All dependency sections are sorted alphabetically:

  • [dependencies]
  • [dev-dependencies]
  • [build-dependencies]
  • [target.'cfg(...)'.dependencies]

Integration

Add to your Makefile:

.PHONY: fmt-toml
fmt-toml:
    @cargo run --package cargo-fmt-toml

.PHONY: check-fmt-toml
check-fmt-toml:
    @cargo run --package cargo-fmt-toml -- --check
Commit count: 53

cargo fmt