Using a dataset corresponding to an integrated luminosity of 3.0 fb$^{-1}$ collected in $pp$ collisions at centre-of-mass energies of 7 and 8 TeV, the $B_s^0 to phi phi$ branching fraction is measured to be [ mathcal{B}(B_s^0 to phi phi) = ( 1.84 pm 0.05 (text{stat}) pm 0.07 (text{syst}) pm 0.11 (f_s/f_d) pm 0.12 (text{norm}) ) times 10^{-5}, ] where $f_s/f_d$ represents the ratio of the $B_s^0$ to $B^0$ production cross-sections, and the $B^0 to phi K^*(892)^0$ decay mode is used for normalization. This is the most precise measurement of this branching fraction to date, representing a factor five reduction in the statistical uncertainty compared with the previous best measurement. A search for the decay $B^0 to phi phi$ is also made. No signal is observed, and an upper limit on the branching fraction is set as [ mathcal{B}(B^0 to phi phi) < 2.8 times 10^{-8} ] at 90% confidence level. This is a factor of seven improvement compared to the previous best limit.