Nitrogen and phosphorus co‐doped hierarchical micro/mesoporous carbon (N,P‐MMC) was prepared by simple thermal treatment of freeze‐dried okra in the absence of any other additives. The 0.96 wt % of N and 1.47 wt % of P were simultaneously introduced into the graphitic framework of N,P‐MMC, which also possesses hierarchical porous structure with mesopores centered at 3.6 nm and micropores centered at 0.79 nm. Most importantly, N,P‐MMC carbon exhibits excellent catalytic activity for electrocatalytic reduction of H2O2, resulting in a new strategy to construct non‐enzymatic H2O2 sensor. The N,P-MMC based H2O2 sensor displays two linear detection range about 0.1 mM–10 mM (R2=0.9993) and 20 mM–200 mM (R2=0.9989), respectively. The detection limit is estimated to be 6.8 μM at a signal-to-noise-ratio of 3. These findings provide insights into synthesizing functional heteroatoms doped porous carbon materials for biosensing applications.