Context. Comets are remnants of the icy planetesimals that formed beyond the ice line in the solar nebula. Growing from μm-sized dust and ice particles to km-sized objects is, however, difficult because of growth barriers and time scale constraints. The gravitational collapse of pebble clouds that formed through the streaming instability may provide a suitable mechanism for comet formation. Aims. We study the collisional compression of silica, ice, and silica/ice-mixed pebbles during gravitational collapse of pebble clouds. Using the initial volume-filling factor and the dust-to-ice ratio of the pebbles as free parameters, we constrain the dust-to-ice mass ratio of the formed comet and the resulting volume-filling factor of the pebbles, depending on the cloud mass. Methods. We use the representative particle approach, which is a Monte Carlo method, to follow cloud collapse and collisional evolution of an ensemble of ice, silica, and silica/ice-mixed pebbles. Therefore, we developed a collision model which takes the various collision properties of dust and ice into account. We study pebbles with a compact size of 1 cm and vary the initial volume-filling factors, φ 0 , ranging from 0.001 to 0.4. We consider mixed pebbles as having dust-to-ice ratios between 0.5 and 10. We investigate four typical cloud masses, M, between 2.6 × 10 14 (very low) and 2.6 × 10 23 g (high). Results. Except for the very low-mass cloud (M = 2.6 × 10 14 g), silica pebbles are always compressed during the collapse and attain volume-filling factors in the range from φ V ≈ 0.22 to 0.43, regardless of φ 0 . Ice pebbles experience no significant compression in very low-mass clouds. They are compressed to values in the range φ V ≈ 0.11 to 0.17 in low-and intermediate-mass clouds (M = 2.6 × 10 17 −2.6 × 10 20 g); in high-mass clouds (M = 2.6 × 10 23 g), ice pebbles end up with φ V ≈ 0.23. Mixed pebbles obtain filling factors in between the values for pure ice and pure silica. We find that the observed cometary density of ∼0.5 g cm −3 can only be explained by either intermediate-or high-mass clouds, regardless of φ 0 , and also by either very low-or low-mass clouds for initially compact pebbles. In any case, the dust-to-ice ratio must be in the range of between 3 ξ 9 to match the observed bulk properties of comet nuclei.