Photocatalytic synthesis of H2O2 is an advantageous and ecologically sustainable alternative to the conventional anthraquinone process. However, achieving high conversion efficiency without sacrificial agents remains a challenge. In this study, two covalent organic frameworks (COF‐O and COF‐C) were prepared with identical skeletal structures but with their pore walls anchored to different alkyl chains. They were used to investigate the effect of the chemical microenvironment of pores on photocatalytic H2O2 production. Experimental results reveal a change of hydrophilicity in COF‐O, leading to suppressed charge recombination, diminished charge transfer resistance, and accelerated interfacial electron transfer. An apparent quantum yield as high as 10.3% (λ = 420 nm) can be achieved with H2O and O2 through oxygen reduction reaction. This is among the highest ever reported for polymer photocatalysts. This study may provide a novel avenue for optimizing photocatalytic activity and selectivity in H2O2 generation.