An on-demand anesthetic that would only take effect when needed and where the intensity of anesthesia could be easily adjustable according to patients' needs would be highly desirable. Here, we design and synthesize a macromolecular prodrug (P407-CM-T) in which the local anesthetic tetracaine (T) is attached to the polymer poloxamer 407 (P407) via a photo-cleavable coumarin linkage (CM). P407-CM-T solution is an injectable liquid at room temperature and gels near body temperature. The macromolecular prodrug has no anesthetic effect itself unless irradiated with a low-power blue light emitting diode (LED), resulting in local anesthesia. By adjusting the intensity and duration of irradiation, the anesthetic effect can be modulated. Local anesthesia can be repeatedly triggered.