Skip to content

Find what’s driving the size 
of your Go binary

bonsai compiles your binary, measures which dependencies drive its size and 
its minimum Go version, and reports how much each one would save if removed.

bonsai TUI

What it does

How bonsai sees your dependencies

Every module lands in one class, and the class decides whether a cut is even possible. The --controlled boundary is the one thing you move, and moving it is how you reach the weight buried deeper in the graph.

1st-class
Your code
Your main module plus anything --controlled matches. Never pruned; bonsai looks for imports to cut out of it.
locked
2nd-class
Direct dependencies
Imported directly by your 1st-class code. The real prune candidates: the surface bonsai can actually cut.
cuttable
↓ widen --controlled to push this boundary deeper
3rd-class
Transitive dependencies
Reached only through other deps. Most of your graph, and where most of the binary's weight hides. A module here only leaves when whatever pulls it in leaves.

Widening --controlled promotes a whole layer of 3rd-class deps into 2nd-class candidates. That is the lever: it exposes the cuttable surface further down and lets bonsai wring out weight that tools reading only your go.mod never see.