The functional importance of Z-DNA — a left-turning helical conformation of DNA — is unclear. Marshall et al. identified an immediate increase in the formation of Z-DNA in neurons in the prefrontal cortex (PFC) of mice that had undergone fear learning. Subsequent fear extinction training led to increases in the levels of the Z-DNA-binding protein ADAR1 in activated PFC neurons, where it bound to more than 100 Z-DNA loci and promoted RNA editing. ADAR1–Z-DNA binding reduced Z-DNA levels, and knock-down of Adar1 disrupted fear extinction learning, suggesting the interaction between Z-DNA and ADAR1 is necessary for memory flexibility.