Coexistence of metallic and semiconducting carbon nanotubes in as-grown samples sets important limits to their application in high-performance electronics. We present the metal-to-semiconductor conversion of carbon nanotubes for field-effect transistors based on both aligned nanotubes and individual nanotube devices. The conversion process is induced by light irradiation, scalable to wafer-size scales and capable of yielding improvements in the channel-current on/off ratio up to 5 orders of magnitude in nanotube-based field-effect transistors. Inactivation of metallic nanotubes in the channels was achieved as a consequence of a diameter-dependent photochemical process that led to a controlled oxidation of the nanotube sidewall and, hence, stronger localization of pi-electrons. Optimization of irradiation conditions yields nearly 90% of depletable nanotube field-effect transistors.