In this study, we use an optogenetic inhibitor of c-Jun NH 2-terminal kinase (JNK) in dendritic spine subcompartments of rat hippocampal neurons. We show that JNK inhibition exerts rapid (within seconds) reorganization of actin in the spine-head. Using real-time Förster resonance energy transfer (FRET) to measure JNK activity, we find that either excitotoxic insult (NMDA) or endocrine stress (corticosterone), activate spine-head JNK causing internalization of AMPARs and spine retraction. Both events are prevented upon optogenetic inhibition of JNK, and rescued by JNK inhibition even 2 h after insult. Moreover, we identify that the fast-acting anti-depressant ketamine reduces JNK activity in hippocampal neurons suggesting that JNK inhibition may be a downstream mediator of its anti-depressant effect. In conclusion, we show that JNK activation plays a role in triggering spine elimination by NMDA or corticosterone stress, whereas inhibition of JNK facilitates regrowth of spines even in the continued presence of glucocorticoid. This identifies that JNK acts locally in the spine-head to promote AMPAR internalization and spine shrinkage following stress, and reveals a protective function for JNK inhibition in preventing spine regression.