The discovery of multiple transiting planetary systems offers new possibilities for characterising exoplanets and understanding their formation. The Kepler-9 system contains two Saturn-mass planets, Kepler-9b and 9c. Using evolution models of gas giants that reproduce the sizes of known transiting planets and accounting for all sources of uncertainties, we show that Kepler-9b (respectively 9c) contains 45−12+17\,\mearth\ (resp. 31−10+13\,\mearth) of hydrogen and helium and 35−15+10\,\mearth (resp. 24−12+10\,\mearth) of heavy elements. More accurate constraints are obtained when comparing planets 9b and 9c: the ratio of the total mass fractions of heavy elements are Zb/Zc=1.02±0.14, indicating that, although the masses of the planets differ, their global composition is very similar, an unexpected result for formation models. Using evolution models for super-Earths, we find that Kepler-9d must contain less than 0.1% of its mass in hydrogen and helium and predict a mostly rocky structure with a total mass between 4 and 16\,\mearth.