As a fascinating conjugated polymer, graphitic carbon nitride (g-CN) has attracted much attention for solving the worldwide energy shortage and environmental pollution. In this work, for the first time we report oxygen self-doping of solvothermally synthesized g-CN nanospheres with tunable electronic band structure via ambient air exposure for unprecedentedly enhanced photocatalytic performance. Various measurements, such as XPS, Mott-Schottky plots, and density functional theory (DFT) calculations reveal that such oxygen doping can tune the intrinsic electronic state and band structure of g-CNvia the formation of C-O-C bond. Our results show that the oxygen doping content can be controlled by the copolymerization of the precursors. As a consequence, the oxygen doped g-CN shows excellent photocatalytic performance, with an RhB photodegradation rate of 0.249 min and a hydrogen evolution rate of 3174 μmol h g, >35 times and ∼4 times higher than that of conventional thermally made pure g-CN (0.007 min and 846 μmol h g, respectively) under visible light. Our work introduces a new route for the rational design and fabrication of doping modified g-CN photocatalyst for efficient degradation of organic pollutants and H production.