Even as four-dimensional (4D) printing of biomaterials evolves as a fascinating technology to engineer complex and dynamic biomimetic parts, the utility of 4D printed hydrogels in addressing clinical needs in vivo has not been established. In this study, a hydrogel system was engineered from tailored concentrations of alginate and methyl cellulose with defined swelling behaviors, which demonstrated excellent printability in extrusion-based three-dimensional (3D) printing and programmed shape deformations post-printing. Shape deformations of the spatially patterned hydrogels with defined infill angles were computationally predicted for a variety of 3D printed structures, which were subsequently validated experimentally. The gels were further coated with gelatin-rich nanofibers by airbrushing to augment cell attachment and growth. 3D printed hydrogel sheets with pre-programmed infill patterns rapidly self-rolled into hollow tubes in vivo to serve as nerve guiding conduits for repairing sciatic nerve defects in a rat model. These 4D printed hydrogels minimized the complexity of surgeries by tightly clamping the resected ends of the nerves to assist in the healing of peripheral nerve damage, as revealed by histological evaluation and functional assessments for up to 45 days. This work demonstrates that 3D printed hydrogels can be designed for programmed shape changes by swelling in vivo to yield 4D printed tissue constructs for the repair of peripheral nerve damage with a potential to be extended in other areas of regenerative medicine.