Stable and efficient noble-metal-free electrocatalysts are imperative substitute of Pt-based electrocatalysts for hydrogen evolution reaction. In this study, N,P-codoped Mo2C/carbon nanofibers prepared via electrospinning and one step heat treatment, exhibited a high dispersion of Mo2C and existence of N and P, which benefit for the electrocatalytic performance of hydrogen evolution reaction. Solving ammonium phosphomolybdate hydrate (PMoHN) in precursor solution, Mo, N and P were introduced in carbon nanofibers, and dosage of PMoHN on electrocatalytic performance was investigated. Subsequently electrochemical tests reveal that 4% (wt. V-1) PMoHN shows the best catalytic performance. The overpotential under acidic (0.5 M H2SO4) and alkaline (1.0 M KOH) conditions are 196 and 107 mV to achieve the current density of 10 mA cm-2, and Tafel slopes are 81.3 and 67.5 mV dec-1 respectively. Moreover, N, P-codoped Mo2C/carbon nanofibers exhibits excellent stability under acidic and alkaline conditions.