Microwaving heating method, which shows significantly higher efficiency in synthesis time and energy utilization than conventional heating method, was firstly applied to synthesize boron doped g-C3N4 (B-g-C3N4). Results demonstrated that B-g-C3N4 could be prepared in 35 min via the method. XRD and XPS analyses verified the successfully doping of B element into the structure of g-C3N4. The doped B improved the photoabsorption performance of g-C3N4. Meanwhile, it greatly hindered the annihilation of charge carriers, prolonging the lifetime of photogenerated electrons, and thereby resulting in the excellent photocatalytic activity. The optimal B-g-C3N4 exhibited a H2 production rate of 1439 and 400 μmol g−1 h−1 under simulated sunlight and visible light irradiation, respectively. This values are about 2.4 times higher than that of pure g-C3N4. This study offered an energy-efficient and rapid way for the synthesis of external atom doped g-C3N4 with high catalytic efficiency.