Ionic liquids and poly(ionic liquid)s have been successfully converted into nitrogen-doped porous carbons with tunable surface area up to 1200 m²/g at high temperatures in air. Compared to conventional carbonization process conducted under inert gas to produce nitrogen-doped carbons, the new production method was completed in a rather shorter time without noble gas protection.