Efficient and low-cost electrocatalysts for the hydrogen evolution reaction are highly desired for future renewable energy systems. Described herein is the reduction of water to hydrogen using a metal-free carbon nitride electrocatalyst which operates in neutral and alkaline environments. An efficient, easy, and general method for growing ordered carbon nitride on different electrodes was developed. The metal-free catalyst demonstrates low overpotential values, which are comparable to those of non-noble metals, with reasonable current densities. The facile deposition method enables the fabrication of many electronic and photoelectronic devices based on carbon nitride for renewable energy applications.