Extreme conditions inside ice giants such as Uranus and Neptune can result in peculiar chemistry and structural transitions, e.g., the precipitation of diamonds or superionic water, as so far experimentally observed only for pure C─H and H2O systems, respectively. Here, we investigate a stoichiometric mixture of C and H2O by shock-compressing polyethylene terephthalate (PET) plastics and performing in situ x-ray probing. We observe diamond formation at pressures between 72 ± 7 and 125 ± 13 GPa at temperatures ranging from ~3500 to ~6000 K. Combining x-ray diffraction and small-angle x-ray scattering, we access the kinetics of this exotic reaction. The observed demixing of C and H2O suggests that diamond precipitation inside the ice giants is enhanced by oxygen, which can lead to isolated water and thus the formation of superionic structures relevant to the planets' magnetic fields. Moreover, our measurements indicate a way of producing nanodiamonds by simple laser-driven shock compression of cheap PET plastics.