For accurate in vivo detection, nonspecific adsorption of biomacromolecules such as proteins and cells is a severe issue. The adsorption leads to electrode passivation, significantly compromising both the sensitivity and precision of sensing. Meanwhile, common antibiofouling modifications, such as polymer coatings, still grapple with issues related to biocompatibility, electrode passivation, and miniaturization. Herein, we propose a composite antibiofouling coating strategy based on zwitterionic metal−organic frameworks (Z-MOFs) and a combination of acrylamide hydrogels. On a well-designed TiO 2 /Z-MOF/hydrogel photoelectrode, we achieve highly sensitive and selective detection of dopamine in complex biological environments. The hydrogel's three-dimensional porous structure combined with unique microporous architecture of Z-MOF ensures effective sieving of interfering macromolecules while preserving efficient small molecules and electron transport. This innovative approach paves the way for constructing miniature, in vivo antibiofouling sensors for molecule monitoring in living organisms with complicated chemical environments.