Energy captured directly from sunlight provides an attractive approach towards fulfilling the need for green energy resources on the terawatt scale with minimal environmental impact. Collecting and storing solar energy into fuel through photocatalyzed water splitting to generate hydrogen in a cost-effective way is desirable. To achieve this goal, low cost and environmentally benign urea was used to synthesize the metal-free photocatalyst graphitic carbon nitride (g-C3N4). A porous structure is achieved via one-step polymerization of the single precursor. The porous structure with increased BET surface area and pore volume shows a much higher hydrogen production rate under simulated sunlight irradiation than thiourea-derived and dicyanamide-derived g-C3N4. The presence of an oxygen atom is presumed to play a key role in adjusting the textural properties. Further improvement of the photocatalytic function can be expected with after-treatment due to its rich chemistry in functionalization.