Chimeric antigen receptor (CAR) T cell-based immunotherapy, approved by the US Food and Drug Administration, has shown curative potential in patients with haematological malignancies. However, owing to the lack of control over the location and duration of the anti-tumour immune response, CAR T cell therapy still faces safety challenges arising from cytokine release syndrome and on-target, off-tumour toxicity. Herein, we present the design of light-switchable CAR (designated LiCAR) T cells that allow real-time phototunable activation of therapeutic T cells to precisely induce tumour cell killing. When coupled with imaging-guided, surgically removable upconversion nanoplates that have enhanced near-infrared-to-blue upconversion luminescence as miniature deep-tissue photon transducers, LiCAR T cells enable both spatial and temporal control over T cell-mediated anti-tumour therapeutic activity in vivo with greatly mitigated side effects. Our nano-optogenetic immunomodulation platform not only provides a unique approach to interrogate CAR-mediated anti-tumour immunity, but also sets the stage for developing precision medicine to deliver personalized anticancer therapy.