Oxygen-enriched boron carbonitrides – known as boron carbon oxinitrides, BCNOs – have exhibited remarkable properties with numerous works reporting on their performance as phosphors and some few ones as H2-adsorbents. However, the study of BCNOs capability for CO2 uptaking has yet to be achieved. Herein, we have designed a simple process for preparation of freestanding three-dimensional (3D) BCNO structures via pyrolysis of supramolecular gels formed by H-bonding of melamine, boric acid and glucose. The 3D porous materials obtained by pyrolysis of supramolecular gels containing glucose exhibited a seaweed-like 3D structure formed by BCNO nanocrystals embedded within a carbonaceous matrix with a certain content of amorphous hydrogenated carbon. The particularly narrow porosities exhibited by these samples proved effective for CO2 adsorption with uptakes of up to ca. 1.8 mmol/g at 25 °C. More interestingly, those samples prepared with high concentration of glucose behaved as molecular sieves and exhibited an excellent performance for CO2–CH4 separation, especially at low pressures with kH values of up to 1.04∙103.