A new approach to preparing porous carbons with desirable pore structure and morphology is demonstrated by using an appropriate pair of polycarboxylic acid/anhydride and diamine in the presence of a metal salt without a sacrificial template.