Histone deacetylases (HDACs) are proteases that can catalyze the deacetylation of histones to inhibit gene transcription. Since mutations and/or aberrant expression of various HDACs are frequently associated with human diseases, particularly cancers, HDACs are important therapeutic targets for many human tumors. However, there are still relatively few studies on HDAC small molecule fluorescent probes. Herein, we designed and synthesized a class of environment-sensitive fluorescent inhibitors with a switch mechanism to study HDAC activity. In vitro, the enzyme inhibition activity of compound 6b was comparable to the positive control drug SAHA, and it presented suitable imaging in living cells and tumor-tissue slices. This environment-sensitive fluorescent inhibitor provides a new idea for the diagnosis and treatment of HDACs-related diseases.