The present report demonstrates a new technique for doping heteroatoms (nitrogen, phosphorus, and sulfur) into carbon materials via a versatile post-treatment. The heat-treatment of carbon materials with a reagent, which is stable at ambient temperatures and evolves reactive gases on heating, in a vacuum-closed tube allows the introduction of various heteroatom-containing functional groups into a carbon matrix. In addition, the sequential doping reactions give rise to dual- and triple-heteroatom-doped carbons. The pore properties of the precursor carbon materials are preserved through each heteroatom doping process, which indicates that independent tuning of heteroatom doping and nanostructural morphology can be achieved in various carbon materials. The electrochemical investigation on the undoped and doped carbon monolithic electrodes applied to supercapacitors provides insights into the effects of heteroatom doping on electrochemical capacitance. The present report demonstrates a new technique for doping heteroatoms (nitrogen, phosphorus, and sulfur) into carbon materials via a versatile post-treatment. The heat-treatment of carbon materials with a reagent, which is stable at ambient temperatures and evolves reactive gases on heating, in a vacuum-closed tube allows the introduction of various heteroatom-containing functional groups into a carbon matrix. In addition, the sequential doping reactions give rise to dual- and triple-heteroatom-doped carbons. The pore properties of the precursor carbon materials are preserved through each heteroatom doping process, which indicates that independent tuning of heteroatom doping and nanostructural morphology can be achieved in various carbon materials. The electrochemical investigation on the undoped and doped carbon monolithic electrodes applied to supercapacitors provides insights into the effects of heteroatom doping on electrochemical capacitance.