The construction of highly efficient and self-supported electrocatalysts with abundant active sites for pH-universal hydrogen evolution reaction (HER) and alkaline water splitting is significantly challenging. Herein, Co and MoC nanoparticles embedded in nitrogen-doped carbon nanofibers (Co-MoC/NCNFs) which display a bamboo-like morphology are prepared by electrospinning followed by the carbonization method. The electrospun MoC possesses an ultrasmall size (≈5nm) which can provide more active sites during electrocatalysis, while the introduction of Co greatly optimizes the electronic structure of MoC. Both endow the Co-MoC/NCNFs with superior HER performances over a wide pH range, with low overpotentials of 86, 116, and 145mV to achieve a current density of 10mAcm-2 in alkaline, acidic, and neutral media, respectively. Additionally, the catalyst exhibits remarkable alkaline oxygen evolution reaction (OER) activity with an overpotential of 254mV to reach 10mAcm-2. Density functional theory calculations confirm that electron transfer from Co to MoC regulates the adsorption free energy for hydrogen, thereby promoting HER. Moreover, an electrolyzer assembled with Co-MoC/NCNFs requires only a cell voltage of 1.59V at 10mAcm-2 in 1m KOH. This work opens new pathways for the design of high-efficiency electrocatalysts for energy conversion applications.