Knowing the structure of the crust is critical to understanding a planet’s geologic evolution. Crustal thickness inversions rely on bulk density estimates, which are primarily affected by porosity. Due to the absence of high-resolution gravity data, Mercury’s crustal porosity has remained unknown. Here, we use a model that was calibrated to the Moon to relate Mercury’s impact crater population and crustal porosity. Therein, porosity is created by large impacts and then decreased as the surface ages due to pore compaction by smaller impacts and overburden pressure. Our preferred model fits independent porosity estimates in the northern regions, where gravity data is well resolved. Porosity is found to be 9 to 17\% with an average and standard deviation of 14$\pm$2\%, indicating lunar-like crustal bulk densities of 2555$\pm$75 kg m$^{-3}$ from which updated crustal thickness maps are constructed. BepiColombo’s improved gravity models will allow comparing porosity generation on Mercury and the Moon.