Methylimidazole compounds are byproducts formed during the caramel-coloring process and are used in various cosmetics. In addition metronidazole is an antibacterial and anti-inflammatory drug commonly used in modern medicine and is used in cosmetics to treat acne in the short-term. The illegal addition of metronidazole during cosmetics production can result in residual 2-methylimidazole (2-MEI), which, along with 4-methylimidazole (4-MEI), is a class 2B carcinogen. Therefore, establishing efficient, accurate, and sensitive analytical techniques for analyzing methylimidazole compounds in cosmetics is an urgent objective. In this study, a high performance liquid chromatography-tandem mass spectrometry (HPLC-MS/MS) method for simultaneously determining 1-methylimidazole (1-MEI), 2-MEI, and 4-MEI in cosmetics was developed. Cosmetics samples were extracted via ultrasonication in acetonitrile and purified using a mixed cation-exchange (MCX) solid-phase extraction (SPE) column, with subsequent drying under a stream of nitrogen and redissolution in acetonitrile. The resulting solution was then filtered through a 0.22 μm organic filter membrane for further testing. The analytes were separated using an XBridge® shield RP18 chromatographic column (150 mm×4.6 mm, 3.5 μm) and isocratically eluted with 20 mmol/L ammonium formate solution (containing 0.1% formic acid)-acetonitrile (98∶2, v/v). The target compounds were ionized by electrospray ionization (ESI) source, analyzed in multi-reaction monitoring (MRM) mode, and quantified using the external standard method, with the peak area of the quantitative ion and the mass concentration of the compound taken as the longitudinal and transverse coordinates, respectively. Matrix-matching working curves were also constructed. 1-MEI exhibited good linear relationships in the range of 5-200 μg/L, with correlation coefficients (r2)≥0.9994, while 2-MEI and 4-MEI showed good linearities in the range of 2-100 μg/L with r2≥0.9984. The three methylimidazole compounds exhibited limits of detection (LODs) and quantification (LOQs) of 10-30 μg/kg and 25-100 μg/kg, respectively. Under three spiked levels (LOQ, 2LOQ, 10LOQ), the recoveries of three methylimidazole compounds were 80.9%-107.9%, with relative standard deviations (RSDs, n=6) of 1.2%-12.8%. The practicability of the method was examined using 48 cosmetic samples; 4-MEI was detected in nine samples at contents of 26-1000 μg/kg, while two samples contained 240 and 267 μg/kg of 2-MEI, respectively. 1-MEI was not detected in any of the 48 samples tested. The developed method is simple, fast, and highly sensitive, and provides methodological support for assessing risks and monitoring the three methylimidazole compounds in cosmetics through screening.