A coarse-grained simulation method to predict NMR spectra of ions diffusing in porous carbons is proposed. The coarse-grained model uses input from molecular dynamics simulations such as the free-energy profile for ionic adsorption, and density-functional theory calculations are used to predict the NMR chemical shift of the diffusing ions. The approach is used to compute NMR spectra of ions in slit pores with pore widths ranging from 2 to 10 nm. As diffusion inside pores is fast, the NMR spectrum of an ion trapped in a single mesopore will be a sharp peak with a pore size dependent chemical shift. To account for the experimentally observed NMR line shapes, our simulations must model the relatively slow exchange between different pores. We show that the computed NMR line shapes depend on both the pore size distribution and the spatial arrangement of the pores. The technique presented in this work provides a tool to extract information about the spatial distribution of pore sizes from NMR spectra. Such information is diffcult to obtain from other characterisation techniques.