The most widely produced compatible solutes in moderately halophilic bacteria are ectoine and hydroxyectoine, which are effective osmostress protectants. So ectoine and hydroxyectoine are the important compatible solutes, which are widely produced by bacteria as protectant against saline and temperature stress. Currently the detection of compatible solutes mainly used by two methods, one is magnetic resonance(NMR) and another one is high performance liquid chromatography(HPLC). While both two methods exist some shortcomings, such as low sensitivity, long detection time, high demand for sample volume and low accuracy, so we need a better method to help researchers do research. An efficient UPLC method for determination ectoine and hydroxyectoine was developed by studying the sample preparation, sample extraction and detection parameters. Results: In the UPLC method, acetonitrile/water (1:99 v/v) as a mobile phase which through at a constant flow rate of 0.4 mL/min was performed on UPLC HSS T3 column, the detection wavelength was 204nm, the injection volume was 1 μL, the temperature of the column was 40 ℃, the standard curve shows a good linear relation(R2=0.9997), and the results have a high recoveries of ectoine and hydroectoine. UPLC method is a higher sensitivity, shorter detection time, lower demand for sample volume and higher accuracy than HPLC and NMR technology.