Narrowband‐ultraviolet B (NB‐UVB) is considered one of the main therapeutic tools in vitiligo, which is able to induce repigmentation and halt depigmentation. However, little remains known about the effect of NB‐UVB on TYR gene family, the main pigmentary genes, in vitiligo patients. To assess the effect of NB‐UVB on expression of some genes related to the pigmentary problem of vitiligo; tyrosinase (TYR), tyrosinase related protein 1 (TYRP1) and tyrosinase related protein 2 (TYRP2), mRNA levels of those genes were quantitatively evaluated by Real‐Time quantitative Polymerase Chain Reaction (RT‐qPCR) in skin biopsies obtained from 30 patients with nonsegmental vitiligo and five healthy controls. Vitiligo patients were classified into two groups; group 1, involving 12 untreated vitiligo patients and group 2, including 18 vitiligo patients treated by NB‐UVB. The levels of TYR, TYRP‐1, and TYRP‐2 mRNAs in untreated group were significantly lower than in control subjects (P < .001). In NB‐UVB treated group, the three genes were significantly higher than in group 1 (P < .001), however, they were still significantly lower than in the control subjects (P < .001). A significant positive correlation was detected between TYR and TYRP‐2 genes in group 2 (P = .03). This study demonstrated that mRNA level of TYR, TYRP‐1, and TYRP‐2, which decreased in vitiligo, was significantly increased upon treatment with NB‐UVB. Accordingly, the mechanism of depigmentation in vitiligo disease and repigmentation by NB‐UVB treatment may be related to the changes in the expression of these genes.