Near-edge X-ray absorption fine structure spectra of pyrimidine and purine at the carbon and nitrogen K-edges were measured using synchrotron radiation and a reflectron time-of-flight mass spectrometer. Spectrum assignments based on the time-dependent density functional theory calculation were presented. From the comparison of the experimental and theoretical results, the nature of various core-excitation transitions and the chemical shifts in the absorption energies were elucidated. The dissociation fragments following the core excitation were analyzed, and the enhancements on the fragment branching ratios were observed. The possible identities and dissociation mechanisms of the major fragments were discussed.