Metal-organic frameworks (MOFs) enable the design of host-guest systems with specific properties. In this work, we show how the confinement of anthracene in a well-chosen MOF host leads to reversible yellow-to-purple photoswitching of the fluorescence emission. This behavior has not been observed before for anthracene, either in pure form or adsorbed in other porous hosts. The photoresponse of the host-guest system is caused by the photodimerization of anthracene, which is greatly facilitated by the pore geometry, connectivity, and volume as well as the structural flexibility of the MOF host. The photoswitching behavior was used to fabricate photopatternable and erasable surfaces that, in combination with data encryption and decryption, hold promise in product authentication and secure communication applications.