Doping hetero-atoms into non-noble metal phosphides, which is a better strategy for enhancement of electrocatalytic activity due to regulation of the electronic structure of catalysts. Herein, the F-doped CoP/Ni2P nanoarrays grown on nickel foam (NF) was fabricated by facile method as a self-supported electrode for hydrogen evolution reaction (HER), and this nanowires structure provide large specific surface area and more active sites. Additionally, the synergy effect between CoP and Ni2P can accelerate the electron transfer rate and increase the reaction rate. Moreover, the addition of strongly electronegative fluorine (F) can cause significant changes in electronic structure and enhance electrocatalytic HER performance. Therefore, the fabricated F-CoP/Ni2P/NF catalyst exhibits excellent HER activity in both alkaline and acidic electrolyte with a lower overpotential of 99 mV and 106 mV at a current density of 10 mA cm−2 and good durability. Hence, this work provides a simple method for exploring heteroatoms-regulated non-precious metal catalysts, which can be used to develop more efficient HER catalysts for water splitting.Graphical abstract: The self-supported fluorine-doped CoP/Ni2P nanowire array was prepared as efficient and stable electrocatalyst for hydrogen evolution reaction in both alkaline and acidic media.