Carbon-based materials have been widely applied in electrochemical field because of good conductivity and low cost. However, the electrochemical performances have been hindered by few active sites in themselves, heteroatom doping is a general method to solve the problem. Herein, boron (B) is doped into the carbon nitride (CN) derived from glucose and melamine by a facile way, and cobalt (Co) is introduced in the B-doped carbon nitride (BNC) to form Co@BNC nanocomposites. Among the different contents of Co in Co@BNC series, 12%Co@BNC shows the best oxygen reduction reaction properties with half-wave potential of 0.78 V, good stability and methanol tolerance in alkaline solution. Besides, 12%Co@BNC also shows oxygen evolution reaction voltage of 1.67 V, and good bifunctional electrocatalysis behaviors with ΔE of 0.89 V. This bifunctional electrocatalyst can be applied in zinc-air batteries for transportation field.