
Voltage-gated sodium channel NaV1.5 is essential for cardiac excitability, mediating the rapid depolarization phase of the cardiac action potential (AP) and ensuring proper electrical conduction in the heart. Dysfunction of NaV1.5 is implicated in life-threatening arrhythmias, making it a critical therapeutic target. Acting as a NaV1.5 open-state blocker, quinidine demonstrates efficacy in arrhythmia treatment, but its low specificity restricts its clinical application. Here, we report an optopharmacological strategy which enables a precise and optical control of NaV1.5 function by means of photoswitchable quinidine derivatives. Through systematic structural optimization, we identify azo-Q2a as a high-performance photoswitchable inhibitor, exhibiting low activity in the dark or under 480 nm light irradiation (trans isomer), while approximately 7-fold higher efficacy is observed under 365 nm light irradiation (cis isomer). Of note, azo-Q2a demonstrates exceptional selectivity for NaV1.5 over cardiac ion channels and other NaV1 subtypes, minimizing potential offtarget effects. Furthermore, by solving the cryo-EM structure of the NaV1.5 in complex with the cis-active isomer azo-Q2a (3.0 Å resolution), we reveal the essential binding site that is responsible for the optical control of NaV1.5. Finally, azo-Q2a also attenuates heart rate of living zebrafish larvae with light, showing its potential in cardiac related research and treatment. Our work not only establishes azo-Q2a as a robust photoswitchable inhibitor for NaV1.5 but also provides a structural blueprint for the rational design of next-generation optopharmacological antiarrhythmic agents.