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^{+17}_{-12}$,mearth (resp. $31^{+13}_{-10}$,mearth) of hydrogen and helium and $35^{+10}_{-15}$,mearth (resp. $24^{+10}_{-12}$,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 $Z_{rm b}/Z_{rm c}=1.02pm 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.