Effectively capturing radioactive iodine formed during nuclear energy utilization is crucial for environment protection and human health. Herein, we present a facile and effective strategy to synthesize a nitrogen-doped hierarchically porous carbon from corn stalks for iodine capture in gaseous and liquid environment. The as-prepared carbon material possesses a hierarchically micro/mesopore structure with highly developed mesopores, a large specific surface area (1892.99 m2 g−1), and suitable nitrogen-doping (2.32 at.%). As a result, the carbon material exhibits efficient iodine capture performance, showing a large capture capacity of 3.14 g g−1 at 80 °C for iodine vapor and a fast removal rate of ∼97 % within 5 min for iodine aqueous solution, outperforming most of carbon-based materials for iodine capture reported in literatures. Thermodynamic and kinetic analyses reveal that the adsorption of iodine vapor conforms to the Langmuir model and pseudo-second-order model, respectively. Density functional theory calculation results indicate that the doped-nitrogen heteroatoms strengthen the interaction between iodine molecules and carbon, which can enhance the affinity for iodine molecules by forming a donor–acceptor complex through the donation of lone-pair electrons, thereby facilitating effective capture of iodine. This work develops a biomass-based porous carbon with potential to efficiently capture radioactive iodine.