Covalent organic frameworks (COFs) are promising materials for advanced molecular-separation membranes, but their wide nanometer-sized pores prevent selective gas separation through molecular sieving. Herein, we propose a MOF-in-COF concept for the confined growth of metal-organic framework (MOFs) inside a supported COF layer to prepare MOF-in-COF membranes. These membranes feature a unique MOF-in-COF micro/nanopore network, presumably due to the formation of MOFs as a pearl string-like chain of unit cells in the 1D channel of 2D COFs. The MOF-in-COF membranes exhibit an excellent hydrogen permeance (>3000 GPU) together with a significant enhancement of separation selectivity of hydrogen over other gases. The superior separation performance for H2/CO2 and H2/CH4 surpasses the Robeson upper bounds, benefiting from the synergy combining precise size sieving and fast molecular transport through the MOF-in-COF channels. The synthesis of different combinations of MOFs and COFs in robust MOF-in-COF membranes demonstrates the versatility of our design strategy