All perfect praise be to Allaah, the Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
We do not know exactly what the melanin in the question is, so please clarify it to us.
However, if you are referring to the substance that is found in the skin of a human being, then this substance does not appear on the skin, as we were informed by some specialists, so it is not judged as pure or impure, but it is a pigment in the skin cells which Allaah has created in the skin of a human being and it determines the color of the skin.
The Global Arabic Encyclopedia reads: “There is a pigment named melanin that determines the color of the skin, so the dark skin has much more melanin than the fair skin...The layers of the human skin contain a brown pigment that is called melanin and it partially protects the skin from ulcerations.”
Allaah Knows best.