Hierarchically porous hybrids of strongly coupled nitrogen-doped porous carbons and graphene aerogel (NPC-GA) are fabricated through the solid-state oxidation polymerization and carbonization of m-phenylenediamine on the interconnected macroporous frameworks of GA. The hierarchically porous hybrids provide abundant storage sites and short transport paths for electrolyte ions. By adjusting the pyrolysis temperature, the specific surface areas and nitrogen content of NPC-GA can be easily modified, further influencing the electrochemical performance of the hybrids. In a three-electrode system, NPC-GA electrode shows high specific capacitance of 608Fg−1 at 0.1Ag−1 in 1M H2SO4. An all-solid-state flexible supercapacitor based on NPC-GA delivers superior energy density (12.4 Wh Kg−1) and power density (2432W Kg−1) as well as good cycling stability (92% specific capacitance retention after 10 000 cycles).