In this study, we described three series of N-phenylpyrimidin-2-amine derivatives as selective TYK2 inhibitors. Systematic exploration of the structure-activity relationship through the introduction of an O-linker and the flexible benzyl substituent based on the reported non-selective JAKs inhibitor yt52 led to the discovery of the optimized derivative compound 29i. Compound 29i showed a potency on TYK2 with an IC50 value of 18 nM and exhibited more than >70-fold selectivity over JAK1/2/3 isoforms. Kinase panel screening, WB assays, and human peripheral blood mononuclear cell assays further validated the selectivity of compound 29i. Compound 29i demonstrated pharmacokinetic properties with an oral bioavailability of 42.7 %. Moreover, in models of inflammatory disease (allergic rhinitis) and autoimmune disease (alopecia areata), compound 29i demonstrated comparable therapeutic effects to market drugs. Taken together, these findings establish that compound 29i is a selective TYK2 inhibitor with compelling potential for clinical development.