Use cargo tree to visualize your Rust project's dependency graph and debug version conflicts or unused crates.
Run cargo tree in your project root to visualize the dependency graph and identify conflicts or unused crates.
cargo tree
For a specific package or to filter by a dependency name, use the -p flag or pipe the output to grep:
cargo tree -p tree | grep serde
To see the full dependency tree including dev and build dependencies, add the --all flag:
cargo tree --all
cargo tree shows you exactly which external libraries your project uses and how they connect to each other. It helps you spot version conflicts where two libraries need different versions of the same tool, or find unused code bloat. Think of it like a family tree for your software, showing who relies on whom.