De novo purine biosynthesis in bacteria relies on an adequate supply of the tetrahydrofolate (THF) derivative 10f-THF. The purine biosynthetic intermediate ZTP (5-aminoimidazole-4-carboxamide riboside 5′-triphosphate) has been proposed to function as a sensor of 10f-THF deficiency, but the mechanism involved is unclear. A new study now shows that a widespread class of riboswitches bind to ZTP and its precursor ZMP (5-aminoimidazole-4-carboxamide ribonucleotide) with nanomolar affinity. Kim et al. show that the binding of the Z-nucleotides to these riboswitches — which are associated with genes involved in purine biosynthesis and central carbon metabolism — triggers the expression of downstream genes to maintain the cellular pool of 10f-THF. Biochemical data indicate that ZTP and ZMP accumulate and are sensed by the riboswitches when 10f-THF is deficient, which activates a gene expression programme to restore the levels of 10f-THF.