Context : Solar and extrasolar planets are the subject of numerous studies aiming to determine their chemical composition and internal structure . In the case of extrasolar planets , the composition is important as it partly governs their potential habitability . Moreover , observational determination of chemical composition of planetary atmospheres are becoming available , especially for transiting planets . Aims : The present works aims at determining the chemical composition of planets formed in stellar systems of solar chemical composition . The main objective of this work is to provide valuable theoretical data for models of planet formation and evolution , and future interpretation of chemical composition of solar and extrasolar planets . Methods : We have developed a model that computes the composition of ices in planets in different stellar systems with the use of models of ice and planetary formation . Results : We provide the chemical composition , ice/rock mass ratio and C : O molar ratio for planets in stellar systems of solar chemical composition . From an initial homogeneous composition of the nebula , we produce a wide variety of planetary chemical compositions as a function of the mass of the disk and distance to the star . The volatile species incorporated in planets are mainly composed of H _ { 2 } O , CO , CO _ { 2 } , CH _ { 3 } OH , and NH _ { 3 } . Icy or ocean planets have systematically higher values of molecular abundances compared to giant and rocky planets . Gas giant planets are depleted in highly volatile molecules such as CH _ { 4 } , CO , and N _ { 2 } compared to icy or ocean planets . The ice/rock mass ratio in icy or ocean and gas giant planets is , respectively , equal at maximum to 1.01 \pm 0.33 and 0.8 \pm 0.5 , and is different from the usual assumptions made in planet formation models , which suggested this ratio to be 2-3 . The C : O molar ratio in the atmosphere of gas giant planets is depleted by at least 30 % compared to solar value . Conclusions :