A zwitterionic stationary phase comprising pyridinium cations and sulfonate anions was successfully developed through thiol-ene click chemistry. Using seven polar small molecules as probes, the zwitterionic stationary phase showed high separation selectivity and excellent column efficiency (35,200–54,800 plates/m) compared with two commercial columns. The influence of water proportion, salt concentration, and pH in the mobile phase, and column temperature, on the retention of six polar compounds was examined. The retention mechanism was explored by three hydrophilic retention models, Tanaka test and linear solvation energy relationship analysis. For the analysis of sample dairy products (milk powder, milk, and yogurt), the stationary phase was operated in hydrophilic interaction chromatography mode without the addition of buffer salts, facilitating rapid and efficient detection and quantification of melamine. The LOD and LOQ are 0.04 mg⋅g−1 and 0.13 mg⋅g−1, respectively, and the recovery rate is 90.3 − 102.8 %. The zwitterionic stationary phase has the advantages of simple preparation, good method reproducibility, good selectivity and high precision.