A Nitrogen-doped carbon was synthesized through the pyrolysis of the well-known metal-organic framework ZIF-8, followed by a subsequent acid treatment, and has been applied as catalyst in the electrochemical reduction of carbon dioxide. The resulting electrode shows Faradaic efficiencies to carbon monoxide as high as ~78%, with hydrogen being the only by-product. Pyrolysis temperature determines the amount and the accessibility of N species in the carbon electrode, in which pyridinic-N and quaternary-N species play key roles in the selective formation of carbon monoxide.