C2 and C3 alkanes are selectively adsorbed from mixtures over the corresponding alkenes on the zeolite imidazolate framework ZIF-7 through a gate-opening mechanism. As a result, the direct production of the pure alkene upon adsorption and the pure alkane upon desorption in packed columns is possible. Herein, a detailed investigation of the step-wise adsorption and separation of alkanes and alkenes is presented, together with a rigorous performance assessment. A molecular picture of the gate-opening mechanism underlying the unprecedented selectivity towards alkane adsorption is proposed based on DFT calculations and a thermodynamic analysis of the adsorption–desorption isotherms.