Materials that are good electrical conductors are not in general optically transparent, yet a combination of high conductivity and transparency is desirable for many emerging opto-electronic applications. To this end, various transparent oxides composed of transition or post-transition metals (such as indium tin oxide) are rendered electrically conducting by ion doping. But such an approach does not work for the abundant transparent oxides of the main-group metals. Here we demonstrate a process by which the transparent insulating oxide 12CaO.7Al2O3 (refs 7-13) can be converted into an electrical conductor. H- ions are incorporated into the subnanometre-sized cages of the oxide by a thermal treatment in a hydrogen atmosphere; subsequent irradiation of the material with ultraviolet light results in a conductive state that persists after irradiation ceases. The photo-activated material exhibits moderate electrical conductivity (~0.3Scm-1) at room temperature, with visible light absorption losses of only one per cent for 200-nm-thick films. We suggest that this concept can be applied to other main-group metal oxides, for the direct optical writing of conducting wires in insulating transparent media and the formation of a high-density optical memory.