Hard X-ray diffraction (XRD) using a nanofocused beam is used to measure both lattice contraction and bending in a single nanowire device under electric bias. The shape of the nanowire is reconstructed in 3D with sub-nm precision. As the bias voltage is gradually increased, nonreversible structural changes in the contact regions are observed, correlated with degradation of the electrical conductance.