Developing efficient electrocatalysts suitable for oilfield wastewater is considered the most crucial aspect of advancing photoelectrochemical water splitting for hydrogen production in arid regions. In this work, Sn-doped cobalt iron hydroxide (SnCoFe-LDH/NF) with a nanoarray structure was successfully prepared in situ on nickel foam using a simple electrodeposition method. The catalyst exhibits high oxygen evolution reaction (OER) activity in 1.0 mol L−1 KOH, requiring only an overpotential of 239 mV to provide a current density of 10 mA cm−2, with a Tafel slope as low as 37.8 mV dec−1. More importantly, it also maintains excellent electrocatalytic activity in 1.0 mol L−1 KOH+oilfield wastewater. The enhancement of electrocatalysis performance can be attributed to the incorporation of Sn ions and layered structure of hydroxide, which increases the inherent activity of the materials, speeds up the kinetics, and improves the synergy between the hydroxides. This study proposes a simple and efficient strategy to prepare cheap and efficient electrocatalysts operating in complex water systems.