Biomass carbon materials which have the merits of green, low cost and renewability, can be obtained from sodium alginate (SA) beads crosslinked by polyvalent metal ions. SA beads are possible to be obtained using diammoniums as the crosslinking agents. In this work, N-O codoped porous carbon (NO-PC) was prepared from SA beads crosslinked by diammoniums through the electrostatic interaction between ammonium cations and carboxylate groups of SA chains. The using of diammoniums as the crosslinkers achieved N doping into NO-PC. Scanning and transmission electron microscope observations revealed that NO-PC possessed hierarchically porous characteristic. X-ray photoelectron spectroscopy identified the successful N-O codoping. Both the species and concentration of diammoniums strongly affected the porous structure, surface area and electrochemical performance of NO-PC. N2 adsorption-desorption results of NO-PC indicated that the highest surface area was up to 3794 m2/g. The NO-PC based supercapacitors showed high specific capacities up to 269.0 F/g at 1 A/g and excellent cycling stability (92.09% after 5000 cycles at 5 A/g). The energy density of the symmetric supercapacitor was up to 18.9 Wh/kg at a power density of 1380 W/kg with a voltage window of -1.4-0 V.