Heteroatom-doped carbon nitride (C 3 N 4 ) with a built-in electric field can reinforce the carrier separation; however, the stability will be greatly reduced due to the loss of surface-doped atoms. Here, molecule self-assembly, as a facile bottom-up approach, is explored for the synthesis and oxygen doping of C 3 N 4 . The obtained C 3 N 4 presents a porous and ultrathin structure and oxygen deep-doping, which generate abundant nitrogen vacancies and a stable built-in electric field. Toward photocatalytic hydrogen evolution, the ultrathin and oxygen deep-doped C 3 N 4 exhibits a 3.5-fold higher activity than bulk C 3 N 4 under simulated sunlight, and 3.6 times higher stability than the oxygen surface-doped counterpart within five cycles. Femtosecond transient absorption spectroscopy indicates the improved carrier separation, and density functional theory (DFT) calculation reveals the promoted H 2 O adsorption and activation under the built-in electric field, which contribute to the excellent photocatalytic performance of oxygen deep-doped ultrathin C 3 N 4 .