High-yielding and selective prebiotic syntheses of RNA and DNA nucleotides involve UV irradiation to promote the key reaction steps and eradicate biologically irrelevant isomers. While these syntheses were likely enabled by UV-rich prebiotic environment, UV-induced formation of photodamages in polymeric nucleic acids, such as cyclobutane pyrimidine dimers (CPDs), remains the key unresolved issue for the origins of RNA and DNA on Earth. Here, we demonstrate that substitution of adenine with 2,6-diaminopurine enables repair of CPDs with yields reaching 92%. This substantial self-repairing activity originates from excellent electron donating properties of 2,6-diaminopurine in nucleic acid strands. We also show that the deoxyribonucleosides of 2,6-diaminopurine and adenine can be formed under the same prebiotic conditions. Considering that 2,6-diaminopurine was previously shown to increase the rate of nonenzymatic RNA replication, this nucleobase could have played critical roles in the formation of functional and photostable RNA/DNA oligomers in UV-rich prebiotic environments.