Ion channels are among the most important proteins in biology, regulating the activity of excitable cells and changing in diseases. Ideally it would be possible to actuate endogenous ion channels, in a temporally precise and reversible manner, and without requiring chemical cofactors. Here we present a modular protein architecture for fully genetically encoded, light-modulated control of ligands that modulate ion channels of a targeted cell. Our reagent, which we call a lumitoxin, combines a photoswitch and an ion channel-blocking peptide toxin. Illumination causes the photoswitch to unfold, lowering the toxin's local concentration near the cell surface, and enabling the ion channel to function. We explore lumitoxin modularity by showing operation with peptide toxins that target different voltage-dependent K(+) channels. The lumitoxin architecture may represent a new kind of modular protein-engineering strategy for designing light-activated proteins, and thus may enable development of novel tools for modulating cellular physiology.