Efficiently removing pharmaceutical pollutants poses a significant challenge for traditional sewage treatment systems. This study presents the synthesis of Zeolitic Imidazole Framework (ZIF-8) using various solvents, including deionized water (DI), isopropyl alcohol (IPA), methyl ethyl ketone (MEK), acetone (ACE), and methanol (MeOH), to degrade two anticancer drugs, 5-fluorouracil (5-FLU) and capecitabine (CAP), under visible light within 80 and 70 min, respectively. Optimized ZIF-8 synthesized using MeOH exhibits uniform hexagonal morphology at the nanoscale and a larger surface area, which, along with its interactions, establishes a synergistic reinforcing mechanism. This mechanism facilitates improved access to reactive sites, enhances the diffusion of pollutants and oxidants, improves charge separation capability, and boosts light utilization efficiency. Consequently, the degradation rates of 5-FLU and CAP approached approximately 99.7 % and 97.9 % following 80 and 70 min of visible light exposure at a pH of 7 in the presence of ZIF-8 (MeOH), indicating superior photocatalytic activity. The studied ZIF-8 (MeOH) system demonstrates excellent stability, maintaining appreciable performance even under visible light for about 70 min. The predominant active species, potential decomposition pathways of CAP, and the underlying reaction mechanism for the ZIF-8 (MeOH)/visible light system have been thoroughly investigated. This research significantly advances the integration of photocatalysis technology, unlocking its tremendous potential in environmental restoration.