A universal method allowing simultaneous extraction and analysis of diverse ultraviolet-B-absorbing compounds belonging to mycosporines and mycosporine-like amino acids (MAAs) is presented. Mycosporines and MAAs are found both in prokaryotes and eukaryotes and possess photoprotective properties. Our method was successfully tested by screening 31 cyanobacterial, 11 actinomycete and 45 fungal strains for their mycosporine and MAA content. The majority of the isolates tested originated from subaerial rock surfaces and were inherently protected from excessive sun irradiation. The new method includes a solid-liquid extraction procedure, followed by a reversed phase liquid chromatography/mass spectrometry. Eight different mycosporines and five MAAs were efficiently separated and identified by their retention times, absorption maxima and fragmentation patterns. Mycosporines were found both in rock-inhabiting fungi and cyanobacteria and consequently may render an ecological marker of these peculiar terrestrial environments.