This paper presents a facile and efficient method for the construction of microporous imide functionalized 1,3,5-triazine frameworks (TPIs@IC), which exhibit high sorption capacities of CO2, CH4and H2, showing potential for small gas separation and recovery.