In the present investigation, undoped, W doped, and W/N co-doped ZnO nanoparticles were prepared by sol–gel route. Here, the ZnO layers were fabricated via the doctor blade method. Hexagonal wurtzite structure is determined by XRD studies. The formation of a hexagonal wurtzite structure was observed from X-ray powder diffraction (XRD) resulting in a slight increase in crystallite size with an increase in doping content. The UV observation shows that W/N co-doping shifted the absorption spectra towards a higher wavelength and reduces the band gap energy. The EDS spectra confirms the high purity and triumphant doping of the W(tungsten) and N(nitrogen) into the ZnO lattice. The morphology of undoped and W/N co-doped ZnO nanoparticles was demonstrated by using FESEM and HRTEM. The 2 % W and 1.5 % N co-doped ZnO photoanode based DSSC (dye-sensitized solar cells) gained the highest short circuit current density of 8.44 mAcm−2 having an open-circuit voltage of 0.65 V, and PCE (power conversion efficiency) of 3.60 %.