Hydrogel materials have great applications in biomedical and flexible optical sensors due to their good flexibility and biocompatibility. In this paper, two hydrogel structures of dye-doped poly(acrylamide-co-poly(ethylene glycol) diacrylate) (p(AM-co-PEGDA)) films and optical fibers were prepared to obtain low threshold and flexible random lasers. The random laser is attributed to the light scattering from the porous structure of the hydrogel, and the random lasing wavelength can be tuned of ∼ 7 nm and ∼ 11.8 nm for the hydrogel film and fiber in the temperature range of 25 to 85 °C, respectively. In addition, the hydrogel film can be bent repeatedly, and the bending strain has a positive effect on the random laser, and the random laser threshold is reduced by 10 μJ/mm2 when the bending strain reaches 47 % for hydrogel film. When the hydrogel optical fiber is stretched to 15 % of its original length, the random laser threshold can be reduced by 12 μJ/mm2.The p(AM-co-PEGDA) hydrogel optical fiber structure has better temperature sensing performance and excellent flexibility than the thin film structure. This work paves a way to extend random laser applications to photothermal therapy, ion detection, and biosensing.