For metal-free carbocatalysts, heteroatom doping and hierarchically porous structure are the significant factors to improve their catalytic performances. Herein, N-, P-co-doped hierarchically porous carbon fiber (NPC–2–800) was prepared by pyrolyzing bamboo pulp in combination with ( NH4)2HPO4 and activator K2CO3. It was found that ( NH4)2HPO4 not only provides N and P atoms, but also significantly affect the morphology and pore structure of the porous carbon. An appropriate dosage of ( NH4)2HPO4 facilitates the formation of hierarchically porous carbon fiber in NPC-2–800. Whereas, the carbon fragments with only micropores were obtained in absence of ( NH4)2HPO4. The hierarchical porosity and the co-doping of N and P atoms in the NPC-2–800 contribute to its outstanding catalytic performances in the 4-Nitrophenol (4-NP) reduction assisted by NaBH4. The NPC-2–800 exhibits an attractive turnover frequency (TOF) value of 4.29 × 10– 4 mmol mg− 1 min− 1, a low activation energy (Ea) of 24.76 kJ/mol, and an acceptable recyclability for 7 cycles without obvious decrease in activity. Kinetics analyses suggest that the 4-NP reduction proceeds through the Langmuir–Hinshelwood model. In addition, the NPC-2–800 can also efficiently catalyze the 2-NP and 3-NP reduction. Moreover, in the real water body, the NPC-2–800 also showed superior catalytic activity to catalyze 4-NP reduction. This study provides an efficient catalyst for pollutant conversion and elimination as well as guidelines for designing versatile carbon-based catalysts.