Porous carbons containing nitrogen were prepared from polyacrylamide using the MgO template method which was produced by magnesium chloride hexahydrate. Particle size range of nanometer MgO was 11-26nm. After carbons were heat-treated at different temperature in inert atmosphere,MgO formed in the carbonization products was dissolved out using a diluted acid. Carbon material were characterized by XRD,SEM,pore parameters test and electrochemical measurement. The results showed that porous carbons were layer structure,average pore size was 4. 72nm. BET surface area of the carbons obtained could be reached to 1873m2/ g. The specific capacitance 176F / g was obtained at a current density 1A/g in H2SO4.