Heteroatom doping along with well-tuned porosity are considered as significant characteristics of a porous carbon material for various potential applications. However, it is a challenging task to tune a single parameter while retaining the other variables unaffected, and this is considered a limiting factor in rational and systematic research. In the present work, in situ nitrogen-enriched microporous carbon materials were prepared by direct carbonization of conjugated porous polyaminals at two different temperatures. To evaluate the role of nitrogen doping in gas adsorption, a comparison was made with commercially available high-surface-area (2093 m(2)/g) microporous petroleum-pitch-based activated carbon (AC) deprived of nitrogen functionalities. It was found that the CO2 adsorption capacity of MPA-2-700, carbonized melamine based polyaminal at 700 degrees C, (186.1 mg/g at 273 K/1 bar with a surface area of 403 m(2)/g) was significantly higher than that of AC (111.0 mg/g at 273 K/1 bar). Our results present valuable insight into designing porous adsorbents with optimized surface polarity and textural characteristics as promising candidates for CO2 capture.