The electronic structure of ZnS and Mg-doped ZnS thin films were calculated by first principle investigation within the density functional theory. For experimental analysis, the ZnS and Mg–ZnS samples were grown by simple one step, chemical bath deposition on a glass substrates. The electronic structure reveals the systematic formation of the intermediate band through Mg substitution in wurtzite ZnS at zinc site. This result is well correlated with the experimental results. The structural results obtained from X-ray diffraction study showed hexagonal wurtzite crystal structure with average crystallite size 23 and 21 nm for ZnS and Mg–ZnS respectively. It is observed from UV–Vis spectra that the energy band gap decreases with Mg content due to the creation of new intermediate bands in the band gap region. Raman spectra obtained from the pure and Mg–ZnS films exhibit the longitudinal optical phonon modes. Photosensing properties of the as-grown ZnS and Mg–ZnS thin films were studied by I-V measurements, the photosensitivity was found to be 92 and 96% respectively.