Clownfishes, with their showy coloration, are well known for their symbiosis with sea anemones and for their hierarchical reproductive system, but the function of their coloration is unclear. We used a phylogeny of 27 clownfish species to test whether fish coloration (i) serves a protective function that involves their anemone hosts, or (ii) signals species identity in species with overlapping host ranges that can potentially share the same host. We tested for an association between fish colour pattern traits, host morphology and host toxicity and examined coloration in relation to host sharing and geographic proximity. Fish with fewer stripes occupied fewer anemone species, and hosts with shorter tentacles, than fish with multiple stripes. There was a negative relationship between anemone toxicity and tentacle length and these protective traits together were correlated with the evolution of stripes. Host sharing or range overlap was not associated with coloration divergence. We propose that ancestral anemonefishes had multiple stripes that served for hiding/camouflage among the hosts’ long tentacles, whereas increased specialization towards fewer and more toxic hosts (with shorter tentacles) led to the use of coloration as an aposematic signal. The intriguing notion that an aposematic signal could advertise the defence of another species may reflect the unique symbiotic relationship between anemonefishes and their hosts.