Ultrathin membranes with intrinsic pores are highly desirable for gas separation applications, because of their controllable pore sizes and homogeneous pore distribution and their intrinsic capacity for high flux. Two-dimensional (2D) covalent organic frameworks (COFs) with layered structures have periodically distributed uniform pores and can be exfoliated into ultrathin nanosheets. As a representative of 2D COFs, a monolayer triazine-based CTF-0 membrane is proposed in this work for effective separation of helium and purification of hydrogen on the basis of first-principles calculations. With the aid of diffusion barrier calculations, it was found that a monolayer CTF-0 membrane can exhibit exceptionally high He and H-2 selectivities over Ne, CO2, Ar, N-2, CO, and CH4, and the He and H-2 permeances are excellent at appropriate temperatures, superior to those of conventional carbon and silica membranes. These observations demonstrate that a monolayer CTF-0 membrane may be potentially useful for helium separation and hydrogen purification.