A molten-salt-induced structural heterogeneity strategy was developed to construct molecular heterostructured carbon nitride with intimately connected heptazine and triazine units, which effectively accelerate charge transport and suppress carrier recombination. Consequently, the prepared CN-2 exhibits significantly enhanced photocatalytic H2O2 production, about 143 times that of traditional carbon nitride.