Carbon degassed from planetary mantles by volcanic activity plays an important role in the planetary surface environment. However, how the carbon content in the Earth's mantle was established is still poorly understood. Here we show that the mantle of planetary embryos may have been nearly saturated with carbon by new high-pressure experiments and pointed out that the carbon solubility of magma is very consistent with the estimated carbon contents in terrestrial and lunar mantles.