ZnO nanowires are promising for photonic devices, biosensor and cancer cell imaging. We have performed a first-principles study to evaluate the electronic and optical properties of ZnO nanowires. We have employed the Perdew–Burke–Ernzerhof form of generalized gradient approximation in the frame work of density functional theory. Calculations have been carried out at different configurations. With decreasing diameter, the band gap of ZnO nanowires is increased due to the increase of quantum confinement effects. The results of imaginary part of the dielectric function indicate that the optical transition between valence band and conduction band has shifted to the high energy range as the diameter decreases. The ZnO nanowires show size-tunable optical properties.