Photocatalysis is a promising way to produce green hydrogen from water under sunlight. However, it is still challenging to develop an efficient photocatalyst for hydrogen production that works under sunlight with high efficiency. In this study, sincere efforts have been made to develop a photocatalyst with enhanced light absorption within the visible spectrum and improved separation of photogenerated electron-hole (e-/h+) pairs. Phosphorus and Nickel codoped TiO2 (PNT) photocatalysts were synthesized through the sol–gel method by varying the amount of phosphoric acid, nickel nitrate, and calcination temperature. Photoluminescence and UV–Vis spectroscopy confirm that codoping enhances the separation of photogenerated e-/h+ pairs as well as improves visible light absorption. Codoped TiO2 had a higher specific surface area and higher pore volume than doped and pure TiO2. 1.5 wt% P and 3.0 wt% of Ni codoped TiO2 calcined at 400 °C (3.0 PNT 400 °C) shows the highest H2 production from water (266.471 μmolg-1h−1) and simulated seawater (148.536 μmolg-1h−1) under solar simulator bulbs in the presence of Ethylene Glycol (10 vol%). This photocatalyst exhibits good stability, with a slight reduction in hydrogen production of 9.15 % in water and 14.8 % in simulated seawater after four cycles.