Melanin is the most common pigment type in animals and plays numerous adaptive roles. However, the effect of diet on melanin pigmentation is not well explored. In particular, it is important to understand how diet influences the cost of melanin production and resource allocation tradeoffs. In this study, we use Hyles lineata, the white-lined sphinx moth, to test whether diet can constrain melanin production and influence potential melanin tradeoffs. In this species, melanin pigmentation is highly plastic during the late larval instars. As in most folivores, amino acids are likely to be a limiting dietary factor. Specifically, we test how the abundance of the amino acid tyrosine, the precursor to melanin synthesis, influences melanin production. We find that diets low in tyrosine can constrain melanin production, even in conditions where melanin is prioritized for thermoregulation (low temperatures and short photoperiods). Larvae raised on low tyrosine diets were both lighter and had less melanin coverage than those raised on high tyrosine diets. Next, we test whether the production of melanin can be costly due to resource allocation tradeoffs with the immune response. We induce high and low melanin forms of final instar larvae feeding on either high or low tyrosine diets and measure immune melanization. This allows us to test whether a tradeoff exists and how diet effects the strength of the tradeoff. Understanding the effect of diet on melanin pigmentation is crucial for explaining why this trait is plastic, and in which contexts it is expressed and prioritized.