The elements hydrogen, carbon and nitrogen are among the most abundant in the solar system. Still, little is known about the ternary compounds these elements can form under the high‑pressure and high‑temperature conditions found in the outer planets’ interiors. These materials are also of significant research interest since they are predicted to feature many desirable properties such as high thermal conductivity and hardness due to strong covalent bonding networks. In this study, the high‑pressure high‑temperature reaction behavior of malononitrile H2C(CN)2, dicyandiamide (H2N)2C=NCN and melamine (C3N3)(NH2)3 was investigated in laser‑heated diamond anvil cells. Two previously unknown compounds, namely α‑C(NH)2 and β‑C(NH)2, have been synthesized and found to have fully sp3‑hybridized carbon atoms. α‑C(NH)2 crystallizes in a distorted β‑cristobalite structure while β‑C(NH)2 is built from previously unknown imide bridged 2,4,6,8,9,10‑hexaazaadamantane units, which form two independent interpenetrating diamond‑like networks. Their stability domains and compressibilities were studied, for which supporting density functional theory calculations were performed.