Animals exhibit dynamic collective behaviors, as observed in flocks of birds, schools of fish, and crowds of humans. The collective behaviors of animals have been investigated in the fields of both biology and physics. In the laboratory, researchers have used various model animals such as the fruit fly and zebrafish for approximately a century, but it has remained a major challenge to study large-scale complex collective behavior orchestrated by these genetically tractable model animals. This paper presents a protocol to create an experimental system of collective behaviors in Caenorhabditis elegans. The propagated worms climb on the lid of the Petri plate and show collective swarming behavior. The system also controls worm interactions and behaviors by changing the humidity and light stimulation. This system allows us to examine the mechanisms underlying collective behaviors by changing environmental conditions and examining the effects of individual-level locomotion on collective behaviors using mutants. Thus, the system is useful for future research in both physics and biology.