Activated carbon was prepared from coconut shell, an agricultural waste, for the removal of phosphorus from synthetic phosphorus‐containing wastewater. The activated carbon obtained from the coconut shell was characterized using Fourier‐transform infrared (FTIR) spectroscopy. Batch mode experiments were conducted to study the effects of pH, particle size, adsorbent dosage, and sorption time on the adsorptive potential of the prepared activated carbon. Response surface methodology was employed to study the interactions among the variables and to optimize the process conditions for the maximum removal of phosphorus using the coconut shell–based activated carbon (CNS). The characterization results from the FTIR showed the presence of variety of functional groups, such as −OH, −NH, C=O, C−H, C−N, CH3, and CH2, which explains the CNS's improved adsorption behavior on the colloidal particles. A maximum performance of 95.22% was obtained for CNS at the optimum conditions of adsorbent dosage = 1,000 milligrams (local variable), pH 2 (local variable), particle size = 0.2 millimeters (local variable), and sorption time = 4.2 hours (global variable).