Hierarchically porous carbon foam (CF) and microporous nitrogen doped carbon foam (NCF) were synthesized at gram scale via the one-step thermal decomposition of metal alkoxides. The total hydrogen uptake of CF reached a maximum of 11.0 wt% at 77 K and 9.5 MPa (or 5.2 wt% excess at 3.9 MPa). This large uptake is attributed to large surface area (3452 m2/g) and pore volume (2.19 cm3/g). Even at room temperature, the total hydrogen uptake reached 2.50 wt% (or 0.94 wt% excess). Nitrogen doping resulted in lower hydrogen uptake at higher pressure, due to the lower surface area. Interestingly however, slightly improved hydrogen uptake was obtained in NCF at lower pressure compared to CF, and we attribute this to the narrower pore size. Meanwhile, the CO2 uptake of CF was 15.2 mmol/g at 273 K and 0.5 MPa. The CO2 uptake of NCF was slightly lower, but the CO2/N2 and CO2/H2 selectivity were higher. This was attributed to increased isosteric heat of adsorption between CO2 and the nitrogen-doped carbon surface. This work shows the potential of bulk-synthesized low-cost metal alkoxide-derived carbon foams to be used in gas storage and separation applications.