We use ab initio density functional calculations to study the formation and structural as well as thermal stability of cellular foamlike carbon nanostructures. These systems with a mixed sp(2)/sp(3) bonding character may be viewed as bundles of carbon nanotubes fused to a rigid contiguous 3D honeycomb structure that can be compressed more easily by reducing the symmetry of the honeycombs. The foam may accommodate the same type of defects as graphene, and its surface may be stabilized by terminating caps. We postulate that the foam may form under nonequilibrium conditions near grain boundaries of a carbon-saturated metal surface.