Porphyrias are disorders of heme metabolism frequently characterized by extreme photosensitivity. This symptom results from accumulation of porphyrins, tetrapyrrole intermediates in heme biosynthesis that generate reactive oxygen species when exposed to light, in the skin of affected individuals. Here we report that in addition to producing an ommochrome body pigment, the planarian flatworm Schmidtea mediterranea generates porphyrins in its subepithelial pigment cells under physiological conditions, and that this leads to pigment cell loss when animals are exposed to intense visible light. Remarkably, porphyrin biosynthesis and light-induced depigmentation are enhanced by starvation, recapitulating a common feature of some porphyrias – decreased nutrient intake precipitates an acute manifestation of the disease. Our results establish planarians as an experimentally tractable animal model for research into the pathophysiology of acute porphyrias, and potentially for the identification of novel pharmacological interventions capable of alleviating porphyrin-mediated photosensitivity or decoupling dieting and fasting from disease pathogenesis. DOI: http://dx.doi.org/10.7554/eLife.14175.001, eLife digest Porphyrias are rare diseases that involve ring-shaped molecules called porphyrins accumulating in various parts of the body. Porphyrins are produced as part of the normal process that makes an important molecule called heme, which is required to transport oxygen. However, high levels of porphyrins can be toxic. For example, porphyrins deposited in the skin can cause swelling and blistering when the skin is exposed to bright light. Other disease symptoms include neurological issues ranging from anxiety and confusion to seizures or paralysis. It has been speculated that porphyrias may have affected several historical figures, including the artist Vincent van Gogh. In addition to their role in heme production, porphyrins also have other roles. For example, they are used as pigments in the wing feathers of some owls. Researchers are trying to understand more about how organisms regulate porphyrin production so that it might be possible to develop more effective treatments for porphyria in humans. Here, Stubenhaus et al. studied how a flatworm called Schmidtea mediterranea makes porphyrins. A group of undergraduate students noticed that these animals – which are normally brown in color – turned white when they were exposed to sunlight for several days. Stubenhaus et al. found that S. mediterranea makes porphyrins in the pigment cells of its skin using the same genes that make porphyrins in humans. Together with other molecules called ommochromes, the porphyrins give rise to the normal color of this flatworm. However, when the animals are exposed to intense light for extended periods of time, which is unlikely to occur in the wild, porphyrin production leads to loss of the pigment cells. The experiments also show that starvation increases the rate of pigment cell loss in light-exposed flatworms, which mirrors the worsening of disease symptoms some porphyria patients experience when they diet or fast. Stubenhaus et al. propose that flatworms are useful models in which to study the molecular processes that are responsible for porphyrias in humans. Further research is required to determine the exact chemical structure of the porphyrin and ommochrome molecules produced in different flatworm species. Stubenhaus et al. also plan to use flatworms to screen for drugs that could potentially be developed into new treatments for porphyria. DOI: http://dx.doi.org/10.7554/eLife.14175.002