Thiazoles and isothiazoles are privileged motifs in drug and agrochemical discovery1,2. The synthesis of these derivatives is generally approached, designed and developed on a case-by-case basis. Sometimes, the lack of robust synthesis methods to a given target can pose considerable difficulties or even thwart the preparation of specific derivatives for further study3,4. Here we report a conceptually different approach in which photochemical irradiation can be used to alter the structure of thiazoles and isothiazoles in a selective and predictable manner. On photoexcitation, these derivatives populate their π,π* singlet excited states that undergo a series of structural rearrangements, leading to an overall permutation of the cyclic system and its substituents. This means that once the initial heteroaromatic scaffold has been prepared, it can then function as an entry point to access other molecules by selective structural permutation. This approach operates under mild photochemical conditions that tolerate many chemically distinct functionalities. Preliminary findings also show the potential for extending this method to other azole systems, including benzo[d]isothiazole, indazole, pyrazole and isoxazole. This strategy establishes photochemical permutation as a powerful and convenient method for the preparation of complex and difficult-to-access derivatives from more available structural isomers.