Nitrogen-enriched porous carbon materials made via the carbonization of polyacrylonitrile containing block copolymer act as efficient and highly selective CO2 sorbents.