Tungsten carbide exhibits platinum-like behavior, which makes it an interesting potential substitute for noble metals in catalytic applications. Tungsten carbide nanocrystals (≈5 nm) are directly synthesized through the reaction of tungsten precursors with mesoporous graphitic C3N4 (mpg-C3N4) as the reactive template in a flow of inert gas at high temperatures. Systematic experiments that vary the precursor compositions and temperatures used in the synthesis selectively generate different compositions and structures for the final nanocarbide (W2C or WC) products. Electrochemical measurements demonstrate that the WC phase with a high surface area exhibits both high activity and stability in hydrogen evolution over a wide pH range. The WC sample also shows excellent hydrogen oxidation activity, whereas its activity in oxygen reduction is poor. These tungsten carbides are successful cocatalysts for overall water splitting and give H2 and O2 in a stoichiometric ratio from H2O decomposition when supported on a Na-doped SrTiO3 photocatalyst. Herein, we present tungsten carbide (on a small scale) as a promising and durable catalyst substitute for platinum and other scarce noble-metal catalysts in catalytic reaction systems used for renewable energy generation.