Excessive residues of tetracycline antibiotics (TCs) are very harmful to the ecosystems and human health, thus it is urgent to establish an effective method for both detection and removal of TCs. Herein, the blue luminescent carbon dots (CDs) were synthesized and modified into a hierarchical mesoporous zeolitic imidazolate framework-8 (HZIF-8) which prepared using hydrogel as template to form CDs@HZIF-8 complex. The blue fluorescence of CDs@HZIF-8 at 440 nm was quenched by TCs through internal filtering effect (IFE), meanwhile, the interaction between TCs and Zn 2+ led to a significant conformational change of TCs, which enhanced the fluorescence at 536 nm. Based on the reverse change of two fluorescence signals ( F 536 / F 440 ), a ratiometric fluorescence sensor was constructed for the detection of TCs. It is worth mentioning that, thanks to the hierarchical porous structure of CDs@HZIF-8, sufficient space is provided for TCs enrichment in the pores and full contact with the skeleton, which improves the adsorption capacity of TCs and significantly enhances the sensitivity of TCs detection. The detection limits of tetracycline (TC), oxytetracycline (OTC) and doxycycline (DOX) were 6.56 nM, 29.46 nM, and 30.58 nM, respectively. Additionally, the rational design method was successfully applied to detect TCs in milk samples. Herein, CDs@HZIF-8 complex was synthesized for simultaneous ratiometric fluorescence detection and removal of tetracycline antibiotics. • CDs@HZIF-8 was synthesized and used as a self-calibrating probe for the detection of tetracycline antibiotics. • The detection limits of tetracycline, oxytetracycline and doxycycline were 6.56 nM, 29.46 nM, and 30.58 nM, respectively. • The rational design method was successfully applied to detect tetracycline antibiotics in milk samples.