Biomass-derived carbon materials have aroused widespread concern as host material of sulfur to enhance electrochemical performances for lithium–sulfur batteries. Herein, goat hair, as a low-cost and eco-friendly precursor, is employed to fabricate cauliflower-like in-situ nitrogen, oxygen and phosphorus tri-doped porous biomass carbon (NOPC) by a facile activation with H3PO4 and carbonization process. The morphology and microstructure of NOPC can be readily tuned by altering pyrolysis temperature. The as-prepared NOPC matrix material carbonized at 600 °C possesses 3D hierarchical porous structure, high specific surface area (535.352 m2 g−1), and appropriate pore size and pore size distribution. Encapsulating sulfur into the NOPC depends on a stem-melting technology as cathode materials of Li–S batteries. Due to the synergistic effect of special physical structure and inherent tri-doping of N, O and P, electrons and ions transfer and utilization of active sulfur in the materials are improved, and the shuttle behaviors of soluble lithium polysulfides are also mitigated. Consequently, the S/NOPC-600 composite exhibits excellent electrochemical performance, giving a high initial discharge capacity of 1185 mA h g−1 at 0.05 C and maintaining a relatively considerable capacity of 489 mA h g−1 at 0.2 C after 300 cycles. Our work shows that a promising candidate for cathode material of Li–S batteries can be synthesized using low-cost and renewable biomass materials by a facile process.