© 2016 Elsevier LtdNanoporous carbon-based composites derived from metal–organic frameworks (MOFs) have drawn increasing attention and hold promising potential in the application of gas adsorption and separation. Herein, we report the preparation and characterization of four novel carbon-based materials, converted from a non-porous Mg-MOF and a porous Zn-MOF which were both constructed by biphenyl-4,4'-dicarboxylic acid (BPDC) as bridging linkers in the structures. The phase transformation and structural evolution of the material were studied by in situ synchrotron powder X-ray diffraction with variable temperature. Interestingly, the results indicate the porosity generated by carbonization would be more dependent on the thermal stability rather than crystallographic intactness of the template MOFs. Moreover, the derived carbon materials selectively adsorb CO2 over N2 at moderate conditions, which would be promising for post-combustion carbon dioxide capture.