The genome of the nematode Caenorhabditis elegans shows far-reaching similarities to that of humans. C. elegans is therefore considered as a powerful model organism in biological research related to humans, for instance for the study of human diseases. Such studies are often based on high-resolution imaging of dynamic biological processes in the worm body tissues, requiring reliable immobilization of the nematodes. However, conventional immobilization methods may strongly affect physiological processes of the animal. Here, we report a new approach for on-chip immobilization of C. elegans nematodes, taking advantage of the elastic properties of polydimethylsiloxane (PDMS). We present two different microdevices, a micropillar array and a serpentine microchannel, respectively, both consisting of size-tunable PDMS structures that allow the same chips to be used for immobilization of worms at all development stages. Our microfluidic approach provides appropriate physiological conditions for long-term studies and enables worm recovery after the experiment. The performance of our devices is demonstrated by two different imaging experiments. The pillar array chip is used for in vivo live imaging of C. elegans embryo fertilization and early embryogenesis, whereas bacterial colonization of a worm's intestine was observed by means of the stretchable microchannel device.