Rationally designed nanoparticles that can bind toxins show great promise for detoxification. However, the conventional intravenous administration of nanoparticles for detoxification often leads to nanoparticle accumulation in the liver, posing a risk of secondary poisoning especially in liver-failure patients. Here we present a liver-inspired three-dimensional (3D) detoxification device. This device is created by 3D printing of designer hydrogels with functional polydiacetylene nanoparticles installed in the hydrogel matrix. The nanoparticles can attract, capture and sense toxins, while the 3D matrix with a modified liver lobule microstructure allows toxins to be trapped efficiently. Our results show that the toxin solution completely loses its virulence after treatment using this biomimetic detoxification device. This work provides a proof-of-concept of detoxification by a 3D-printed biomimetic nanocomposite construct in hydrogel, and could lead to the development of alternative detoxification platforms.