ABSTRACT The core-accretion model for giant planet formation suggests a two-layer picture for the initial structure of Jovian planets, with heavy elements in a dense core and a thick H–He envelope. Late planetesimal accretion and core erosion could potentially enrich the H–He envelope in heavy elements, which is supported by the threefold solar metallicity that was measured in Jupiter’s atmosphere by the Galileo entry probe. In order to reproduce the observed gravitational moments of Jupiter and Saturn, models for their interiors include heavy elements, Z, in various proportions. However, their effect on the equation of state of the hydrogen–helium mixtures has not been investigated beyond the ideal mixing approximation. In this article, we report results from ab initio simulations of fully interacting H–He–Z mixtures in order to characterize their equation of state and to analyze possible consequences for the interior structure and evolution of giant planets. Considering C, N, O, Si, Fe, MgO, and SiO2, we show that the behavior of heavy elements in H–He mixtures may still be represented by an ideal mixture if the effective volumes and internal energies are chosen appropriately. In the case of oxygen, we also compute the effect on the entropy. We find the resulting changes in the temperature–pressure profile to be small. A homogeneous distribution of 2% oxygen by mass changes the temperature in Jupiter’s interior by only 80 K.