Cubic ordered mesoporous carbon co-doped with N and P shows a high specific capacitance of 210 F g−1 at 1.0 A g−1 and excellent retention of specific capacitance with more than 90% of initial capacitance at a high current density of 10 A g−1 and also for 3000 charge–discharge cycles.