ZnO nanoparticles were synthesised via sol–gel method, and then, deposited on a glass substrate using the spin-coating procedure to hand in ZnO thin films. In order to study the effect of alkaline sol on different properties of ZnO thin films, the pH value of sol was adjusted with ammonia. Then, the structural, optical, and photoelectrochemical properties of the prepared samples were analysed. According to XRD analyses, by increasing pH values, the size of ZnO particles increases and the films’ crystallinity improves. In addition, SEM micrographs affirm the uniformity of thin films. According to AFM findings, the morphology and roughness of the samples’ surface are affected by pH values in such a way that with increasing the pH, the roughness of the surface decreases, and the crystallinity improves. Also, both UV–vis peaks shift towards lower wavelengths with increasing pH value of ZnO sol. This means that the more the pH values of ZnO sol, the more the excitation energy of electrons. On the other hand, the numerical values of the energy bandgap decrease by increasing pH. According to PL results, the increase of pH causes the separated electrons and holes to have more energy and can move away from each other. So, the recombination process rate decreases; this result affirms by EIS findings. Increasing the optical absorption and reducing charge recombination are in favour of the photocatalytic reactions. Clearly, increasing the pH value causes the stable photocurrent to increase and the threshold voltage of (J-V) diagram to decrease. Also, the samples show recognisable sensitivity to light. As a final result, the best suggested amount of pH to fabricate ZnO photoanods for water splitting is 10.5.