Similarity of nitroimidazole and nitrofuran antibiotics in molecular structure and photophysical properties makes them difficult to distinguish via luminescence sensing technology. Herein, this is solved by a dye-encapsulated lanthanide metal-organic framework luminescent sensor.