Rapid and accurate detection of fentanyl in unknown products and aqueous samples can find the unexpected existence of the toxic chemical and assist law enforcement. In this paper, novel colorimetric biosensors for fentanyl and one of its metabolites, norfentanyl, are designed and fabricated by incorporating an enzyme-linked immunosorbent assay (ELISA) onto three dimensionally macroporous framework melamine foam (MF). The MF-based ELISA sensors (f-ELISA) have performance features of ultrahigh sensitivity, selectivity, and on-site detection without using any laboratory instruments. The lowest visually distinguishable concentration of fentanyl in wastewater is 0.005 mg L−1 by naked eye and can be further improved to 0.001 mg L−1 with the aid of a smartphone. Furthermore, by increasing sample volume, the sensitivity of the f-ELISA sensor can reach naked-eye detection of fentanyl at concentrations as low as 0.0005 mg L−1, a volume-responsive signal enhancement, and a special structural advantage provided by the macroporous structure of the foam. The norfentanyl f-ELISA sensor can reveal a lowest visually distinguishable concentration of 0.001 mg L−1 in PBS buffer for both naked-eye and smartphone analysis. The new biosensors can overcome limitations of current techniques in detecting fentanyl and its derivatives in fluids and are suitable for on-site use.