B, N co-doped porous carbon is fabricated by using chitosan as a carbon precursor, boric acid as a boron source and porogen, and ferric chloride as a multifunctional reagent (i.e., solvent, template, and activator). This strategy results in large amounts of micropores and especially mesopores that are beneficial for electrolyte ions diffusion. The as-synthesized carbon has abundant micropores and mesopores, desirable pore distribution, partial graphite structure, and dual heteroatoms doping, and thus outstanding supercapacitance performances. In a three-electrode system, the B, N co-doped porous carbon shows a high specific capacitance of 393 F g–1 at 0.5 A g–1. In a two-electrode system, the porous carbon exhibits a high capacitance of 205 F g–1 at 1.0 A g–1, and its energy density is high up to 19.1 Wh kg–1 at a power density of 400 W kg–1. Furthermore, the porous carbon exhibits excellent supercapacitance in ionic liquid electrolyte. In addition, the porous carbon possesses excellent cycling stability.