Chemical compositions of giant planets provide a means to constrain how and where they form . Traditionally , super-stellar elemental abundances in giant planets were thought to be possible due to accretion of metal-rich solids . Such enrichments are accompanied by oxygen-rich compositions ( i.e . C/O below the disc ’ s value , assumed to be solar , \mathrm { C / O } = 0.54 ) . Without solid accretion the planets are expected to have sub-solar metallicity , but high C/O ratios . This arises because the solids are dominated by oxygen-rich species , e.g . H _ { 2 } O and CO _ { 2 } , which freeze out in the disk earlier than CO , leaving the gas metal poor but carbon-rich . Here we demonstrate that super-solar metallicities can be achieved by gas accretion alone when growth and radial drift of pebbles are considered in protoplanetary discs . Through this mechanism planets may simultaneously acquire super-solar metallicities and super-solar C/O ratios . This happens because the pebbles transport volatile species inward as they migrate through the disc , enriching the gas at snow lines where the volatiles sublimate . Furthermore , the planet ’ s composition can be used to constrain where it formed . Since high C/H and C/O ratios can not be created by accreting solids , it may be possible to distinguish between formation via pebble accretion and planetesimal accretion by the level of solid enrichment . Finally , we expect that Jupiter ’ s C/O ratio should be near or above solar if its enhanced carbon abundance came through accreting metal rich gas . Thus Juno ’ s measurement of Jupiter ’ s C/O ratio should determine whether Jupiter accreted its metals from carbon rich gas or oxygen rich solids .