Biomass shows great potential in synthesizing carbon materials for energy applications because of its renewability and low price. Rationally designing porous carbons with proper morphology and composition are beneficial to promoting its application in energy storage devices. Here, an environmentally friendly approach is proposed to prepare three-dimensional (3D) N, P co-doped hierarchical porous carbon (NP-HPC) for supercapacitors. The 3D cross-linked porous network not only promotes the infiltration of electrolytes, but also boosts the transportation of ion/electron. The high microporosity combined with heterogeneous doping provides more defects and active sites, improving the surface charge storage. Hence, the NP-HPC electrode achieves a high capacitance of 358 F g−1 at 0.05 A g−1 as well as good rate performance of 238 F g−1 at 50 A g−1. Moreover, NP-HPC-based all-solid-state supercapacitor exhibits a long lifespan over 10,000 cycles. The impressive performance of NP-HPC indicates the potential of biomass-derived porous carbons for supercapacitors through simultaneous morphology and doping engineering.