Porous carbon nitride (CN) spheres with partially crystalline frameworks have been successfully synthesized via a nanocasting approach by using spherical mesoporous cellular silica foams (MCFs) as a hard template, and ethylenediamine and carbon tetrachloride as precursors. The resulting spherical CN materials have uniform diameters of ca. 4 μm, hierarchical three-dimensional (3-D) mesostructures with small and large mesopores with pore diameters centered at ca. 4.0 and 43 nm, respectively, a relatively high BET surface area of ~550 m 2 /g, and a pore volume of 0.90 cm 3 /g. High-resolution transmission electron microscope (HRTEM) images, wide-angle X-ray diffraction (XRD) patterns, and Raman spectra demonstrate that the porous CN material has a partly graphitized structure. In addition, elemental analyses, X-ray photoelectron spectra (XPS), Fourier transform infrared spectra (FT-IR), and CO 2 temperature-programmed desorption (CO 2 -TPD) show that the material has a high nitrogen content (17.8 wt%) with nitrogen-containing groups and abundant basic sites. The hierarchical porous CN spheres have excellent CO 2 capture properties with a capacity of 2.90 mmol/g at 25 °C and 0.97 mmol/g at 75 °C , superior to those of the pure carbon materials with analogous mesostructures. This can be mainly attributed to the abundant nitrogen-containing basic groups, hierarchical mesostructure, relatively high BET surface area and stable framework. Furthermore, the presence of a large number of micropores and small mesopores also enhance the CO 2 capture performance, owing to the capillary condensation effect.