Dynamic changing process of pH-sensitive anthocyanin solutions was monitored by time-resolved ultraviolet–visible (UV–vis) absorption spectroscopy. Two-dimensional correlation spectroscopy (2DCOS) and principal component analysis (PCA) were further used to investigate the spectral data associated with chemical structure change of anthocyanin. The addition of acid resulted in the narrowing and blueshift of the absorption band of the anthocyanin solution around 528 nm. This may be caused by the formation of flavylium cation from carbinol pseudobase. The addition of alkali led to synchronous changes of the absorption bands around 528 and 607 nm, implying the conversion of flavylium cation to quinonoidal base. 2DCOS data suggested that the peak assigned to flavylium cation during the structural conversion could be located at 520 nm, which was rarely found in the time-resolved absorption spectra. Silk fabric was dyed with anthocyanin and used as a colorimetric pH sensor. The flexible pH sensing fabric showed visual sensitivity to pH changes, with great reusability and stability. The wearable pH fabric sensors fabricated from sustainable and renewable natural biomaterials have potential applications in environmental monitoring, medicine and smart clothing.