Biomass walnut shell was used to prepare activated carbon (AC) through a carbonization treatment and an activation procedure with potassium hydroxide (KOH). AC showed hierarchical pores: 0.6 nm micropores, 2.7 nm mesopores and macropores with average diameter of 50 nm, providing a large specific surface area of 2318 m2 g−1. This highly porous AC was tested as a host material to encapsulate sulfur via a vapor phase infusion process. The developed AC-S electrode showed a high initial specific capacity of 1350 mAh g−1 and good capacity retention over 100 cycles at 0.1 C for lithium–sulfur battery.