We present a systematically improvable density fitting scheme designed for accurate Coulomb potential evaluation of periodic and molecular systems. The method does not depend on the way the density is calculated, allowing for a basis set expansion as well as a numerical representations of the orbitals. The scheme is characterized by a partitioning of the density into local contributions that are expanded by means of cubic splines. For three-dimensional periodic systems, the long-range contribution to the Coulomb potential is treated with the usual reciprocal space representation of the multipole moments, while in one- and two-dimensional systems, it is calculated via a new algorithm based on topological extrapolation. The efficiency and numerical robustness of the scheme is assessed for a number of periodic and nonperiodic systems within the framework of density-functional theory. © 2014 American Chemical Society.