Graphitic carbon nitride (g-C3N4) has attracted extensive attention in energy storage due to its suitable and tunable bandgap, high chemical/thermal stability, earth abundance and environmental friendliness. However, its conductivity should be improved to work as the electrode materials in supercapacitors. In this report, we have prepared a two-dimensional composite (CN-PANI) based on g-C3N4 and polyaniline (PANI) by in-situ polymerization, which can be efficiently applied as electrode material for supercapacitors. The introduction of PANI can increase the conductivity of the electrode, and the porous structure of g-C3N4 can provide enough channels for the transport of electrolyte ions and improve the electrode stability. As a result, the obtained CN-PANI demonstrates excellent specific capacitance (234.0 F g− 1 at 5 mV/s), good rate performance and high cycling stability (86.2% after 10,000 cycles at 50 mV/s), showing great potential for high-rate supercapacitors.