This study investigates the strong photoluminescence (PL) and X-ray excited optical luminescence observed in nitrogen-functionalized 2D graphene nanoflakes (GNFs:N), which arise from the significantly enhanced density of states in the region of {pi} states and the gap between {pi} and {pi}* states. The increase in the number of the sp2 clusters in the form of pyridine-like N-C, graphite-N-like, and the C=O bonding and the resonant energy transfer from the N and O atoms to the sp2 clusters were found to be responsible for the blue shift and the enhancement of the main PL emission feature. The enhanced PL is strongly related to the induced changes of the electronic structures and bonding properties, which were revealed by the X-ray absorption near-edge structure, X-ray emission spectroscopy, and resonance inelastic X-ray scattering. The study demonstrates that PL emission can be tailored through appropriate tuning of the nitrogen and oxygen contents in GNFs and pave the way for new optoelectronic devices.