In optical devices like diffraction gratings and Fresnel lenses, light wavefront is engineered through the structuring of device surface morphology, within thicknesses comparable to the light wavelength. Fabrication of such diffractive optical elements involves highly accurate multi-step lithographic processes that in fact set into stone both the device morphology and optical functionality. In this work, we introduce shapeshifting diffractive optical elements directly written on an erasable photoresist. We first develop a lithographic configuration that allows writing/erasing cycles of aligned optical elements directly in the light path. Then, we show the realization of complex diffractive gratings with arbitrary combinations of grating vectors. Finally, we demonstrate a shapeshifting diffractive lens that is reconfigured in the light-path in order to change the imaging parameters of an optical system.