The response of DNA and RNA bases to ultraviolet (UV) radiation has been receiving increasing attention for a number of important reasons: (i) the selection of the building blocks of life on an early earth may have been mediated by UV photochemistry, (ii) radiative damage of DNA depends critically on its photochemical properties, and (iii) the processes involved are quite general and play a role in more biomolecules as well as in other compounds. A growing number of groups worldwide have been studying the photochemistry of nucleobases and their derivatives. Here we focus on gas phase studies, which (i) reveal intrinsic properties distinct from effects from the molecular environment, (ii) allow for the most detailed comparison with the highest levels of computational theory, and (iii) provide isomeric selectivity. From the work so far a picture is emerging of rapid decay pathways following UV excitation. The main understanding, which is now well established, is that canonical nucleobases, when absorbing UV radiation, tend to eliminate the resulting electronic excitation by internal conversion (IC) to the electronic ground state in picoseconds or less. The availability of this rapid "safe" de-excitation pathway turns out to depend exquisitely on molecular structure. The canonical DNA and RNA bases are generally short-lived in the excited state, and thus UV protected. Many closely related compounds are longer lived, and thus more prone to other, potentially harmful, photochemical processes. It is this structure dependence that suggests a mechanism for the chemical selection of the building blocks of life on an early earth. However, the picture is far from complete and many new questions now arise.