Improperly treated or directly discharged into the environment, wastewater containing dyes can destroy the quality of water bodies and pollute the ecological environment. The removal of dye wastewater is urgent and essential. In this study, corn stalk was pyrolyzed to pristine biochar (CSBC) in a limited oxygen atmosphere and modified using KOH and H 3 PO 4 (KOH-CSBC, H 3 PO 4 -CSBC, respectively). The biochars were characterized by surface area and pore size, X-ray diffraction (XRD), Fourier transform infrared (FTIR) spectroscopy, X-ray photoelectron spectroscopy (XPS), as well as their behavior in adsorbing methylene blue (MB). Results indicated that the pore structure of CSBC became more developed after modification by KOH. Meanwhile, H 3 PO 4 -CSBC contained more functional groups after activation treatment. The pseudo-second-order kinetic and the Langmuir adsorption isotherm represented the adsorption process well. The maximum MB adsorption capacity of CSBC, KOH-CSBC, and H 3 PO 4 -CSBC was 43.14 mg g −1 , 406.43 mg g −1 and 230.39 mg g −1 , respectively. Chemical modification significantly enhanced the adsorption of MB onto biochar, especially for KOH-CSBC. The adsorption mechanism between MB and biochar involved physical interaction, electrostatic interaction, hydrogen bonding and π-π interaction. Hence, modified CSBC (especially KOH-CSBC) has the potential for use as an adsorbent to remove dye from textile wastewater.