Chirality-selective functionalization of semiconducting single-walled carbon nanotubes (SWCNTs) has been a difficult synthetic goal for more than a decade. Here we describe an on-demand covalent chemistry to address this intriguing challenge. Our approach involves the synthesis and isolation of a chemically inert diazoether isomer that can be switched to its reactive form in situ by modulation of the thermodynamic barrier to isomerization with pH and visible light that resonates with the optical frequency of the nanotube. We found that it is possible to completely inhibit the reaction in the absence of light, as determined by the limit of sensitive defect photoluminescence (less than 0.01% of the carbon atoms are bonded to a functional group). This optically driven diazoether chemistry makes it possible to selectively functionalize a specific SWCNT chirality within a mixture. Even for two chiralities that are nearly identical in diameter and electronic structure, (6,5)- and (7,3)-SWCNTs, we are able to activate the diazoether compound to functionalize the less reactive (7,3)-SWCNTs, driving the chemical reaction to near exclusion of the (6,5)-SWCNTs. This work opens opportunities to chemically tailor SWCNTs at the single chirality level for nanotube sorting, on-chip passivation, and nanoscale lithography.