This study proposes an efficient, facile, and scalable strategy to synthesize in situ heteroatom-doped porous graphene via laser direct writing on the precursor-doped polyimide (PI) film, which is fabricated for the first time through incorporating PI powder and precursors with sodium carboxymethyl cellulose (CMC) binder by a drop-casting and low-temperature drying process. The resulting microsupercapacitors (MSCs) based on the as-prepared heteroatom-doped porous graphene exhibit remarkable capacitive performance. The typical boron-doped MSC prepared on borax-doped polyimide film possesses an ultrahigh areal capacitance of 60.6 mF cm-2 at 0.08 mA cm-2, which is approximately 20 times larger than that of undoped MSC. Furthermore, the boron-doped MSC has impressive cycling stability (with the capacitance retention of 96.3% after 20 000 cycles), exceptional mechanical flexibility, tunable capacitance, and voltage output through arbitrary modular serial and parallel integration. Besides, the nitrogen-doped porous graphene with excellent capacitive performance is also prepared by laser direct scribing on the sulfonated melamine-doped polyimide film, demonstrating excellent scalability and generality of this strategy. Hence, one-step laser direct writing on precursor-doped polyimide films can realize in situ heteroatom doping and generation of hierarchical porous graphene electrodes simultaneously, which opens a new avenue for the facile, cost-effective, and scalable fabrication of heteroatom-doped porous graphene, thus promising for MSCs and various flexible and wearable electronics at large-scale production.