This work reports an efficient strategy to synthesize B,N-codoped porous carbons with a high specific surface area using chitosan as the carbon precursor with the help of boric acid, featuring a high specific capacitance, large operation voltage and excellent cycle stability for supercapacitors.