  We establish a precise relation between the modular bootstrap, used to
constrain the spectrum of 2D CFTs, and the sphere packing problem in Euclidean
geometry. The modular bootstrap bound for chiral algebra $U(1)^c$ maps exactly
to the Cohn-Elkies linear programming bound on the sphere packing density in
$d=2c$ dimensions. We also show that the analytic functionals developed earlier
for the correlator conformal bootstrap can be adapted to this context. For
$c=4$ and $c=12$, these functionals exactly reproduce the "magic functions"
used recently by Viazovska [1] and Cohn et al. [2] to solve the sphere packing
problem in dimensions 8 and 24. The same functionals are also applied to
general 2D CFTs, with only Virasoro symmetry. In the limit of large central
charge, we relate sphere packing to bounds on the black hole spectrum in 3D
quantum gravity, and prove analytically that any such theory must have a
nontrivial primary state of dimension $\Delta_0 \lesssim c/8.503$.
