Exploring highly active and stable electrocatalyst for oxygen evolution reaction is important for the development of water splitting and rechargeable metal-air batteries. Herein, a hybrid electrocatalyst of CoFe alloy and CoxN heterojunction encapsulated and embedded in N-doped carbon support (CoFe-CoxN@NC) was in situ coupling via a pyrolysis process of a novel coordination polymer from lignin biomacromolecule. CoFe-CoxN@NC exhibited an excellent OER activity with a low overpotential of 270 mV at 10 mA•cm−2 and stability with increment of 20 mV, comparable to commercial Ir/C. DFT calculations revealed that CoxN and N-doped grapheme encapsulation can reduce the binding strength between *O and CoFe alloy, prevent metals leaching and agglomeration, and improve electron transfer efficiency, thereby, remarkably enhancing the OER activity and stability. In situ coupling strategy of alloy and nitride heterojunction on N-doped lignin-derived carbon provided a promising and universal catalyst design for the development of renewable energy conversion technologies.