Abstract Work function is a fundamental property of metals and is related to many surface-related phenomena of metals. Theoretically, it can be calculated with a metal slab supercell in density functional theory (DFT) calculations. In this paper, we discuss how the commensurability of atomic structure with the underlying fast Fourier transform (FFT) grid affects the accuracy of work function obtained from plane-wave pseudopotential DFT calculations. We show that the macroscopic average potential, which is an important property in work function calculations under the ‘bulk reference’ method, is more numerically stable when it is calculated with commensurate FFT grids than with incommensurate FFT grids. Due to the stability of the macroscopic average potential, work function calculated with commensurate FFT grids shows better convergence with respect to basis set size, vacuum length and slab thickness of a slab supercell. After we control the FFT grid commensurability issue in our work function calculations, we obtain well-converged work functions for Al, Pd, Au and Pt of (100), (110) and (111) surface orientations. For all the metals considered, the ordering of our calculated work functions of the three surface orientations agrees with experiment. Our findings reveal the importance of the FFT grid commensurability issue, which is usually neglected in practice, in obtaining accurate metal work functions, and are also meaningful to other DFT calculations which can be affected by the FFT grid commensurability issue.