Porous carbons are widely used in energy storage and gas separation applications, but their synthesis always involves high temperatures. Herein we electrochemically selectively extract, at ambient temperature, the metal atoms from the ternary layered carbides, Ti3AlC2, Ti2AlC and Ti3SiC2 (MAX phases). The result is a predominantly amorphous carbide-derived carbon, with a narrow distribution of micropores. The latter is produced by placing the carbides in HF, HCl or NaCl solutions and applying anodic potentials. The pores that form when Ti3AlC2 is etched in dilute HF are around 0.5 nm in diameter. This approach forgoes energy-intensive thermal treatments and presents a novel method for developing carbons with finely tuned pores for a variety of applications, such as supercapacitor, battery electrodes or CO2 capture.