Bottom-gate and top-contact thin-film transistors with ZnO film as a channel layer were fabricated by sol–gel method. The structural and optical properties of the deposited ZnO films were investigated through X-ray diffractometer, scanning electron microscopy and UV–Vis spectrophotometer. ZnO film has a high absorption in the ultraviolet region and c-axis orientation normal to the substrate. The on/off current ratio, channel mobility and threshold voltage of ZnO-based thin-film transistors in dark are 105, 0·02 cm2 V−1 s−1 and 8·3 V, respectively. Under UV light illumination (λ = 365 nm) with an intensity of 2·4 μW/cm2, the drain–source current IDS of thin-film transistor dramatically increases and the photo-to-dark current ratio is greater than 104. The transient response of the device to ultraviolet illumination is also discussed. The results may open the possibility of employing ZnO-thin-film transistors as UV photodetector.