Band gap narrowing is important for applications of ZnO, especially for photoelectrochemical water splitting. In this work, we carried out first-principles electronic structure calculations with a hybrid density functional on defected ZnO. It is found that nitrogen substitutional doping alone cannot explain the largely enhanced conversion efficiency observed in nitrogen doped ZnO. Instead, complex defects formed by substitutional nitrogen and intrinsic defects play an important role in the band gap narrowing, in agreement with recent experimental results. We propose ZnO fabricated in a Zn-rich environment with heavy nitrogen doping as a photocatalyst for hydrogen generation from water splitting. A method for controlling the band gap of ZnO is also proposed.