In recent years, polybenzoxazine aerogels have emerged as promising materials for various applications. However, their full potential has been hindered by the prevalent use of hazardous solvents during the preparation process, which poses significant environmental and safety concerns. In light of this, there is a pressing need to explore alternative methods that can mitigate these issues and propel the practical utilization of polybenzoxazine aerogels. To address this challenge, a novel approach involving the synthesis of heteroatom self-doped mesoporous carbon from polybenzoxazine has been devised. This process utilizes eugenol, stearyl amine, and formaldehyde to create the polybenzoxazine precursor, which is subsequently treated with ethanol as a safer solvent. Notably, the incorporation of boric acid in this method serves a dual purpose: it not only facilitates microstructural regulation but also reinforces the backbone strength of the material through the formation of intermolecular bridged structures between polybenzoxazine chains. Moreover, this approach allows ambient pressure drying, further enhancing its practicability and environmental friendliness. The resultant carbon materials, designated as ESC-N and ESC-G, exhibit distinct characteristics. ESC-N, derived from calcination, possesses a surface area of 289 m2 g-1, while ESC-G, derived from the aerogel, boasts a significantly higher surface area of 673 m2 g-1. Furthermore, ESC-G features a pore size distribution ranging from 5 to 25 nm, rendering it well suited for electrochemical applications such as supercapacitors. In terms of electrochemical performance, ESC-G demonstrates exceptional potential. With a specific capacitance of 151 F g-1 at a current density of 0.5 A g-1, it exhibits superior energy storage capabilities compared with ESC-N. Additionally, ESC-G displayed a more pronounced rectangular shape in its cyclic voltammogram at a low voltage scanning rate of 20 mV s-1, indicative of enhanced electrochemical reversibility. The impedance spectra of both carbon types corroborated these findings, further validating the superior performance of ESC-G. Furthermore, ESC-G exhibits excellent cycling stability, retaining its electrochemical properties even after 5000 continuous charge-discharge cycles. This robustness underscores its suitability for long-term applications in supercapacitors, reaffirming the viability of heteroatom-doped polybenzoxazine aerogels as a sustainable alternative to traditional carbon materials.