Zeolite imidazolate framework-8 (ZIF-8) was used as the novel sorbent for on-line solid-phase extraction coupled with high-performance liquid chromatography (HPLC) for the determination of oxytetracycline (OTC), tetracycline (TC) and chlorotetracycline (CTC) in water and milk samples. 390mg of ZIF-8 was packed into a stainless steel column (3cm long×4.6mm i.d.) which was mounted on the HPLC injector valve to replace the sample loop. On-line solid-phase extraction of OTC, TC and CTC was achieved by loading sample solution at a flow rate of 3.0mLmin−1 for 10min with the aid of a flow-injection system. The extracted analytes were subsequently eluted into a C18 analytical column (25cm long×4.6mm i.d.) for HPLC separation under isocratic condition with a mobile phase (10% MeOH–20% ACN–70% 0.02molL−1 oxalic acid solution) at a flow rate of 1.0mLmin−1. Under optimized conditions, the developed method gave the enhancement factors of 35–61, the linearity range of 5–1000μgL−1, the detection limits of 1.5–8.0μgL−1, quantification limits of 5.0–26.7μgL−1, uncertainties of 0.9–1.1μgL−1, and the sample throughput of 4 samples h−1. The recoveries of OTC, TC and CTC at 50μgL−1 in water and milk samples ranged from 70.3% to 107.4%.