The Ni-P-WS2 composite coatings with prominent structures were constructed by composite electrodeposition by adding tungsten disulfide (WS2) nanoparticles to the electroplating solution. Modification of the Ni-P-WS2 composite coating with hexadecyltrimethoxysilane (HDTMS) is going to achieve the superhydrophobic effect. The successful construction of the superhydrophobic surface was demonstrated by X-ray diffractometer (XRD), scanning electron microscopy (SEM), X-ray photoelectron spectroscopy (XPS), and contact angle measurement (CA). Electrochemical impedance spectroscopy (EIS) was used to investigate the corrosion resistance. The finding indicates that hexadecyltrimethoxysilane (HDTMS) reduces the surface energy of the Ni-P-WS2 composite coating, generates a film on its rough surface, blocks the corrosive medium, and improves the corrosion resistance of the composite coating. The Ni-P-WS2 nanocomposite coating's water contact angle is 156.8° and its sliding angle is 8° at 3 g/L of WS2 particle concentration. And the composite plating has the highest self-corrosion potential (Ecorr = − 0.285 V) and the lowest self-corrosion current density (icorr = 3.206 μA cm−2), with a better corrosion resistance. In addition, the prepared superhydrophobic coating showed excellent corrosion resistance under the hydrophobic barrier and the layer barrier of WS2 nanosheets. [ABSTRACT FROM AUTHOR]