Oxygen reduction reaction (ORR), oxygen evolution reaction (OER) and hydrogen evolution reaction (HER) are the rate-controlling and/or energy-intensive reactions of numerous energy conversion and storage devices. It is a great challenge to attain a high catalytic efficiency with a single electrocatalyst towards these reactions simultaneously. Herein, a porous carbon was prepared by pyrolysis of chitin with the assistance of CoCl2 and ZnCl2 and a subsequent sulfurization process, which resulted in uniform loading of Co, N and S elements. The porous and modified carbon exhibited high catalytic performance towards ORR, OER and HER. Furthermore, the catalyst was used as air electrode to construct Zn-air batteries, which showed a power of 142 mW cm−2 and discharging and charging voltages of 1.3 V and 1.74 V at 1 mA cm−2 after 100 cycles, respectively. When used as both the anode and cathode for water splitting, the voltage to achieve a 10 mA cm−2 electrolysis current was 1.58 V which was stable over 75 h of operation. The performance enhancement is attributed to the etching effect which generates defects in both carbonaceous matrix and the Co9S8 crystallites during the sulfurization, as well as the doping of S and N elements which creates multiple active sites.