• Four heptazine-based porous organic polymers with different diamines were prepared. • The structure–activity relationships of the POPs have been systematically studied. • The diamine linker has important roles on its physicochemical property and activity. • POP-4 has the best performance for the photocatalytic oxidation of benzylamine. • Its conversion and selectivity of benzylamine oxidation are both>99 %. Heptazine-based porous organic polymers (POPs), as new potential photocatalytic materials, have spurred extensive research interest, but there are few reports on the systematic study of the relationship between their structure and properties. Herein, we have prepared four heptazine-based POPs by using cyameluric chloride (C 6 N 7 Cl 3 ) as precursor, piperazine (POP-1), p-phenylenediamine (POP-2), biphenyl diamine (POP-3) and 4,4′'-diamino-p-terphenyl (POP-4) as basic blocks, respectively, and studied the effects of the composition and structure of POPs on their spectrum, specific surface area, interface contact in acetonitrile, electronic structure, carrier separation and photocatalytic aerobic oxidation of amine through experiments and density functional theory (DFT) calculations systematically. The results show that with the increase of the benzene rings and electron density of diamine linker, the electron-donating ability of these heptazine-based POPs significantly enhances, which reduces the band gap of the materials, improves their electronic donor–acceptor (D-A) interaction with heptazine, promotes the transfer and separation of photogenerated carriers, and thus endowing them significantly higher photocatalytic performance. Notably, POP-4 shows the best photocatalytic aerobic oxidation activity of benzylamine, which is significantly higher than that of g-C 3 N 4 . The conversion and selectivity of benzylamine to corresponding imine are both>99 % within 4 h under 10 W 420 nm LED light irradiation. This work paves the way for the rational design of efficient heptazine-based POP photocatalysts and promotes the development of heptazine-based functional materials.