Supercapacitors have attracted intensive research interest due to their advantages including longer cycling ability and higher power density. Porous heteroatom-doped carbons (PHCs) have been regarded as a class of promising electrode materials for supercapacitors because of their unique porous, electronic and chemical properties. However, synthesis of PHCs with hierarchical mesoporous/microporous structures and ultra-high porosity and electrochemical performance remains a great research challenge. In this research, two oxygen and nitrogen co-doped PHCs (denoted as ONC-T1s) are prepared via a salt-assisted pyrolysis method using covalent organic frameworks (COFs) as the precursor. ONC-T1s show a hierarchical porous structure with an ultra-high specific surface area (up to 3451 m2 g−1). The ONC-T1-850-based supercapacitor exhibits a high specific capacitance of 1711 F g−1 at 1 A g−1, an ultra-fast charge–discharge rate up to 500 A g−1 with a specific capacitance of 856 F g−1, and excellent stability. This work establishes a promising strategy for preparation of PHCs using COFs or other porous organic polymers as precursors and demonstrates the great potential of PHC-based supercapacitors.