Mesoporous carbon-doped hexagonal boron nitrides (C-doped BN) with high surface area were prepared by annealing organic resin polymer/silica in NaBH4 and NaNH2 inorganic salts, which were found to be efficient metal-free bifunctional electrocatalyst for both 2e− ORR and 2e− WOR. It could efficiently catalyze 2e− ORR to H2O2 in 2 M KHCO3 (1650 mmol g−1 h−1) with Faraday efficiency of 93–98 % in half reaction, while it was very active for 2e− WOR to generate H2O2 in 2 M KHCO3 with 551 mmol g−1 h−1 H2O2 production rate in half reaction. When pairing them in one H-type cell, H2O2 solution could be totally produced over C-doped BN in both anode and cathode cells. The better electron conductivity from sharper band gap caused by carbon doping and higher surface area of 304 m2 g−1 contributed to its efficient electrocatalytic activity. The C-doped BN served an effective bifunctional electrocatalyst for 2e− ORR and 2e− WOR.