The nitrogen doping generally plays an important role in alkali-ion storage. Herein the nitrogen doping effect on K+ storage in graphite foam is explored. Experimental and theoretical calculations reveal that the K+ storage behavior is strongly dependent on nitrogen doping concentration and doping configurations. Specifically, high doping level i) provides more pyridinic/pyrrolic nitrogen content, thus creating more holey structures for K+ storage, ii) enlarges interlayer spacing to facilitate K+ intercalation, and iii) increases electronic conductivity to ensure fast kinetics. For the first time, we proved that the holey structure, rather than nitrogen doping, contributes to the capacity enhancement for carbon-based potassium ion batteries. Our investigations promote better understanding of K+ ion storage mechanism in doped graphite and provide invaluable guidance to optimize carbon-based electrode design for high-performance potassium ion batteries.