Optopharmacology is a very promising approach based on the use of light-deliverable drugs, which allows manipulating physiological processes with high spatiotemporal resolution. Light-dependent drugs (i.e. caged-compounds) targeting G protein-coupled receptors (GPCRs) have been developed to provide great pharmacological precision on the control of pain. Metabotropic glutamate type 5 (mGlu) receptors are widely expressed through the pain neuraxis and play a key role in pain transmission. In line with this, selective mGlu receptor negative allosteric modulators (NAMs) have consistently shown analgesic activity in experimental animal models of inflammatory pain. Accordingly, we synthesized a light-deliverable drug (i.e. caged compound) using the chemical structure of raseglurant, a mGlu receptor NAM, as a molecular scaffold. And thereafter, we evaluated the analgesic activity of the caged compound in formalin-injected (hind paw) mice upon light irradiation (405 nm). Of note, light was both delivered at the peripheral (i.e. hind paw) and central level (i.e. thalamus), by means of brain-implanted fiber-optics. The novel light-deliverable drug, JF-NP-26, showed antinociceptive activity upon violet light irradiation either of the hind paw or the thalamus, demonstrating the ability of precisely activating, in time and space, the caged compound. Here, we describe in detail the protocol used to perform a reliable and reproducible formalin nociception test in mice using an optopharmacology approach (i.e. light-deliverable compounds).