The disposal of coffee shell waste on farmland, is a common practice that can causing the environmental and waste valuable resources. Carbonization has been identified as an effective method for transforming coffee shells into useful products that mitigate environmental pollution. Through the response surface methodology, the carbonization conditions of the coffee shells were optimized and its potential as a biochar-based slow-release urea fertilizer was explored. Experiments were conducted on coffee shell performance under varying carbonization conditions such as temperature (600–1000 °C), time (1–5 h), and heating rate (5–20 °C/min). The results indicated that the ideal urea adsorption was 56.3 mg/g, achieved under carbonization conditions of 2.83 h, 809 °C, and 15.3 °C/min. The optimal nutrient release rate within seven days was 45.4% under carbonization conditions of 3.19 h, 813 °C, and 15.0 °C/min. The infrared spectroscopy analysis indicates that carbonization conditions influenced the absorption peak intensity of coffee shell biochar, while the functional group types remain unchanged. The biochar exhibits diverse functional groups and abundant pores, making it a promising candidate for use as a biochar-based fertilizer material. Overall, the findings demonstrate an effective waste management approach that significantly reduces environmental pollutants while remediating pollution.