Doping oxygen as a secondary heteroatom into nitrogen-doped carbon materials triggers synergistic electronic promoting effect that optimizes the electronic structure and the polarity of adjacent carbon atoms, significantly boosting ambient ammonia synthesis.