A measurement of the branching fraction of the decay $B_s^0 to K_S^0 K_S^0$ is performed using proton-proton collision data corresponding to an integrated luminosity of 5 $fb^{-1}$ collected by the LHCb experiment between 2011 and 2016. The branching fraction is determined to be BR($B_s^0 to K_S^0 K_S^0$) = [8.3 $pm$ 1.6 (stat) $pm$ 0.9 (syst) $pm$ 0.8 (norm) $pm$ 0.3 ($f_s/f_d$)] $times 10^{-6}$ , where the first uncertainty is statistical, the second is systematic, and the third and fourth are due to uncertainties on the branching fraction of the normalization mode $B^0 to phi K_S^0$ and the ratio of hadronization fractions $f_s/f_d$. This is the most precise measurement of this branching fraction to date. Furthermore, a measurement of the branching fraction of the decay $B^0 to K_S^0 K_S^0$ is performed relative to that of the $B_s^0 to K_S^0 K_S^0$ channel, and is found to be $frac{BR(B^0 to K_S^0 K_S^0)}{BR(B_s^0 to K_S^0 K_S^0)}$ = [7.5 $pm$ 3.1 (stat) $pm$ 0.5 (syst) $pm$ 0.3 ($f_s/f_d$)] $times 10^{-2}$.