|These unsightly white worms are flatworms. They're not parasitic, and won't harm your fish. They're thought to be introduced into the aquarium through food (both live and dried). When water conditions are poor, and contain high levels of nitrates and large amounts of biological matter, such as fish waste, these worms can grow and multiply.
To rid your aquarium of pesky flatworms, try removing all your fish and placing them in a temporary holding tank. Then, increase the water temperature above 95°F for several hours. If this doesn't kill the flatworms, try a water treatment that specifically targets parasites, such as CopperSafe, Clout, or Fluke Tabs.
To prevent future infestation, consider upgrading your filtration system. Undergravel filters are typically not efficient mechanical filters. Aquariums with undergravel filters usually require weekly water changes and thorough gravel vacuuming. Consider adding another filter that employs more efficient mechanical filtration. A canister filter or power filter offers an effective solution. Both are easily maintained and require that you simply change the mechanical and chemical cartridge when it becomes clogged with debris.
Most importantly, be sure to clean your aquarium regularly, control nitrate levels in the water, maintain your filter, and perform frequent water changes to prevent problems with pests like flatworms.