We developed fluorogenic probes, which are photoactivated in the presence of specific nucleic acid templates with the release of fluorescent dyes. This templated reaction can be used to target specific nucleic acids in complex mixtures. We further demonstrate that this reaction can be monitored by single-molecule fluorescence imaging.