Melatonin, a product of tryptophan metabolism via serotonin, is a molecule with an indole backbone that is widely produced by bacteria, unicellular eukaryotic organisms, plants, fungi and all animal taxa. Aside from its role in the regulation of circadian rhythms, it has diverse biological actions including regulation of cytoprotective responses and other functions crucial for survival across different species. The latter properties are also shared by its metabolites including kynuric products generated by reactive oxygen species or phototransfomation induced by ultraviolet radiation. Vitamins D and related photoproducts originate from phototransformation of ∆5,7 sterols, of which 7‐dehydrocholesterol and ergosterol are examples. Their ∆5,7 bonds in the B ring absorb solar ultraviolet radiation [290–315 nm, ultraviolet B (UVB) radiation] resulting in B ring opening to produce previtamin D, also referred to as a secosteroid. Once formed, previtamin D can either undergo thermal‐induced isomerization to vitamin D or absorb UVB radiation to be transformed into photoproducts including lumisterol and tachysterol. Vitamin D, as well as the previtamin D photoproducts lumisterol and tachysterol, are hydroxylated by cyochrome P450 (CYP) enzymes to produce biologically active hydroxyderivatives. The best known of these is 1,25‐dihydroxyvitamin D (1,25(OH)2D) for which the major function in vertebrates is regulation of calcium and phosphorus metabolism. Herein we review data on melatonin production and metabolism and discuss their functions in insects. We discuss production of previtamin D and vitamin D, and their photoproducts in fungi, plants and insects, as well as mechanisms for their enzymatic activation and suggest possible biological functions for them in these groups of organisms. For the detection of these secosteroids and their precursors and photoderivatives, as well as melatonin metabolites, we focus on honey produced by bees and on body extracts of Drosophila melanogaster. Common biological functions for melatonin derivatives and secosteroids such as cytoprotective and photoprotective actions in insects are discussed. We provide hypotheses for the photoproduction of other secosteroids and of kynuric metabolites of melatonin, based on the known photobiology of ∆5,7 sterols and of the indole ring, respectively. We also offer possible mechanisms of actions for these unique molecules and summarise differences and similarities of melatoninergic and secosteroidogenic pathways in diverse organisms including insects.