Nucleotide binding triggers a conformational change of the CBS module of the magnesium transporter CNNM2 from a twisted towards a flat structure.