TiO2 -based organic–inorganic composite films doped with azobenzene and photosensitive groups were prepared by combining a low-temperature solgel technique and a spin-coating method. The influence of TiO2 content on the optical and structural properties of the composite films including the film thickness, the refractive index, the transmission loss, the thermal gravity analysis, and Fourier transform infrared spectroscopy spectra was studied. Photoisomerization and optical switching characteristics of the composite film were investigated under the irradiation of 365 nm ultraviolet light and 450 nm visible light. Results indicate that several micrometer thick films can be easily obtained at room temperature and there is a proportional relationship between the refractive index value and the TiO2 content. In addition, the composite films have a low optical propagation loss of about 0.1 dB/cm. The composite films with 0.2 M TiO2 content have an obvious photoisomerization and good optical switching properties. Finally, the hexagonal microlens array was fabricated in the composite films by using an ultraviolet nanoimprint technology. All these results above indicate that the as-prepared TiO2 -based organic–inorganic composite film has potential applications in optical switching devices and photonic elements.