The invention provides nitrogen mixed grapheme hydrogel of which the water content is 90 to 99.5 percent, the electric conductivity is 10-3-100 S/m, and the molar ratio of N and C is 1 to 25 percent. The invention further provides nitrogen mixed aerogel of which the molar ratio of N and C is 2 to 20 percent, the molar ratio of C and O is 15 to 5, nitrogen atoms existing in the form of amidogen nitrogen accounts for 40 to 70 percent, pyridine type nitrogen accounts for 10 to 40 percent, graphite type nitrogen accounts for 10 to 30 percent, the specific area is 300 to 1500 m<2>/g, the apertures which are micropore account for 10 to 20 percent, the apertures which are mesoporous 20 to 50 percent, the apertures which are macropore 30 to 70 percent, the apparent density is 0.01 to 0.2 g/cm<3>, the pore volume is 5 to 20 cm<3>/g, and the electric conductivity is 1 to 1000 S/m. The nitrogen mixed grapheme hydrogel or aerogel and preparation method thereof provided by the invention has the characteristics that the operation is simple, the equipment requirement is low, the production efficiency is high, the scale-up of the technology is easy, the nitrogen mixed content is controllable and the compounding with other functional substances is simple.