Nitrogen-enriched porous and layered graphitic carbon materials (N-PLGCs) were prepared by the thermal annealing of polyaniline (PANI)/melamine composites. The effects of nitrogen groups and structural features on the electrochemical performance of N-PLGCs were investigated. It was found that PANI served as a substrate and layered graphitic carbons were formed by thermal annealing of melamine. Flower-like carbons were formed with optimized PANI/melamine ratio. The nitrogen groups and specific surface area of N-PLGCs increased with increasing melamine content, resulting in enhanced electrochemical performance. Indeed, the N-PLGCs showed excellent electrochemical performance with the high specific capacitance (218F/g) at a scan rate of 0.1A/g as well as good rate capability. These results indicate that the porous and layered features of N-PLGC lead to feasible ion transfer during charge/discharge duration and the presence of high nitrogen groups on the N-PLGC electrode could provide a pseudocapacitive effect.