Degradation of organic pollutants is an important research area to solve environmental issues. Metal-free carbon nitride (C 3 N 4 ) materials have a great potential as cost-effective and environment-friendly photocatalysts for this purpose. Herein, we develop a route to produce mesoporous C 3 N 4 materials and investigate their photocatalytic performance for degrading rhodamine B (RhB). The mesoporous materials are generated through the self-assembly of melamine and cyanuric acid during high-temperature pyrolysis. The materials show excellent photocatalytic activities for RhB degradation under the irradiation of visible light. They possess higher surface areas, better adsorption ability of visible light and longer lifetimes of the photoexcited electrons than common C 3 N 4 sample. These aspects are the reasons for the excellent photocatalytic performance.