TL;DR — Quick Summary

cargo-bloat shows what takes the most space in your Rust binary. Find the biggest functions, crates, and dependencies — then optimize for smaller binaries.

cargo-bloat tells you why your Rust binary is big. Find the bloat, fix the bloat.

Installation

# Cargo
cargo install cargo-bloat

Usage

# Biggest functions in release build
cargo bloat --release

# Per-crate breakdown
cargo bloat --release --crates

# Top N functions
cargo bloat --release -n 30

# Filter by function name
cargo bloat --release --filter serde

# Show all functions (no limit)
cargo bloat --release -n 0

# Specific target
cargo bloat --release --target wasm32-unknown-unknown

# Wide output (full function names)
cargo bloat --release -w

# Time comparison (before/after)
cargo bloat --release --message "before optimization"

Summary

  • cargo-bloat shows what takes space in Rust binaries
  • Per-function and per-crate size breakdown
  • Filter by name, limit results, wide output
  • WASM target support for web assembly optimization
  • Essential for Rust binary size optimization