Hard carbon draws great interests as anode material in lithium ion batteries (LIBs) due to its high theoretical capacity, high rate capability and abundance of its precursors. Herein we firstly synthesize the lignin-melamine resins by grafting melamine onto lignin. Afterwards, nitrogen doped hard carbon is prepared by the pyrolysis of lignin-melamine resins with the aid of catalyst (Ni(NO3)2·6H2O) at 1000 °C. Compared with the samples without nitrogen-doping and catalysis, as-prepared nitrogen doped hard carbon exhibits higher reversible capacity (345 mAh g–1 at 0.1 A g−1), higher rate capability (145 mAh g−1 at 5 A g–1) and excellent cycling stability. The superior electrochemical performance is ascribed to the synergistic effect of nitrogen doping, graphitic structure and amorphous structure. Among them, nitrogen doping could create the vacancies around the nitrogen sites, which enhance the reactivity and the electronic conductivity of materials. Additionally, graphitic structure also enhances the electronic conductivity of materials, thus improving the electrochemical performance of hard carbon. It is worthwhile that lignin, renewable and abundant biopolymer, is converted to hard carbon with good electrochemical performance, which realizes the high value utilization of lignin.