Graphitic carbon nitride (g-C3N4) has attracted enormous research attention as a promising low cost, visible-light driven semiconductor photocatalyst. However, low photoabsorption efficiencies and unsatisfactory charge separation limit the potential of g-C3N4 in many applications, motivating attempts to manipulate the structure and electronic properties of g-C3N4 to achieve improved performance. Here we describe a novel precursor-reforming strategy that ultimately affords 3D mesoporous ultrathin g-C3N4 with superior photocatalytic performance compared to conventional calcination-derived g-C3N4. We demonstrate that during hydrothermal treatment of melamine and urea, melamine undergoes an irreversible monoclinic to orthorhombic phase transformation, and the additive urea (excess typically 3-fold) serves as an additional N source and porogen. Calcination of the orthorhombic melamine yields mesoporous g-C3N4 with enhanced photoabsorption properties and an outstanding photoactivity. A 23-fold increased hydrogen evolution rate of 3579μmolh−1g−1 (λ > 420nm) was achieved with an apparent quantum efficiency (AQE) of 27.8% at 420 ± 15nm, a level of performance far beyond any AQE previously reported for ultrathin/porous/doped g-C3N4 photocatalyst. Our work conclusively demonstrates a new synthetic strategy towards high performance g-C3N4-based photocatalytic materials for energy applications.