By a novel phase-transition-assisted strategy, the porosity of carbon materials can be fine tuned from the micrometer to the nanometer level, and the functionality of carbon surfaces can be better controlled to achieve an excellent performance for the catalysis of the oxygen reduction reaction.