Membrane-based water treatment processes offer possibility to alleviate the water scarcity dilemma in energy-efficient and sustainable ways, this has been exemplified in filtration membranes assembled from two-dimensional (2D) materials for water desalination purposes. Most representatives however tend to swell or disintegrate in a hydrated state, making precise ionic or molecular sieving a tough challenge. Here we report that the chemically robust 2D carbon nitride can be activated using aluminum polycations as pillars to modulate the interlayer spacing of the conjugated framework, the noncovalent interaction concomitantly affords a well-interlinked lamellar structure, to be carefully distinguished from random stacking patterns in conventional carbon nitride membranes. The conformally packed membrane is characterized by adaptive subnanochannel and structure integrity to allow excellent swelling resistance, and breaks permeability-selectivity trade-off limit in forward osmosis due to progressively regulated transport passage, achieving high salt rejection (>99.5%) and water flux (6 L m−2 h−1), along with tunable permeation behavior that enables water gating in acidic and alkaline environments. These findings position carbon nitride a rising building block to functionally expand the 2D membrane library for applications in water desalination and purification scenarios.